Skip to content

Commit 64f2bba

Browse files
committed
Fixed sst_view_parse.pl incorrect detection of correlation IDs
Modifications to instrument_file_cpp.py for SYCL support and new requirement for explicit perfstubs finalize call
1 parent daefd65 commit 64f2bba

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

app/sst_view_parse.pl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#FOUND NEW ATTRIBUTE: counter 0 {Elements:1 Type:string Value:"Correlation ID" }
6363
}elsif($line=~m/counter\s(\d+)\s.*Value:\"Correlation ID\"/){
6464
$corid_cidx=$1;
65-
65+
print "Correlation id maps to counter $corid_cidx\n";
6666

6767
#Parse GPU device/context
6868
#FOUND NEW ATTRIBUTE: MetaData:0:7:CUDA Context {Elements:1 Type:string Value:"1" }
@@ -160,15 +160,17 @@
160160
$cval = $3;
161161
$ts = $4;
162162

163-
if(exists($corids{$cval})){
164-
print "Found matching corid $cval\n";
165-
delete $corids{$cval};
166-
$ncorid_matched++;
167-
}else{
168-
print "Found new corid $cval\n";
169-
$corids{$cval} = [$thread, $cid, $cval, $ts];
163+
if($cid == $corid_cidx){
164+
if(exists($corids{$cval})){
165+
print "Found matching corid $cval\n";
166+
delete $corids{$cval};
167+
$ncorid_matched++;
168+
}else{
169+
print "Found new corid $cval\n";
170+
$corids{$cval} = [$thread, $cid, $cval, $ts];
171+
}
170172
}
171-
173+
172174
$counter_n++;
173175
if($counter_n == $counter_nrows){
174176
$counter_active = 0;

scripts/instrument_file_cpp.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def func_keyword_check(start, tokens, keywords):
265265
#Use perfstubs, which automatically collects the function info
266266
toins = "PERFSTUBS_SCOPED_TIMER_FUNC();"
267267
if func.name == "main":
268-
toins = "PERFSTUBS_INITIALIZE(); " + toins
268+
toins = "PS_SCOPED_INIT(); " + toins
269269

270270
orig = flines[iline]
271271
#print("Line %d char %d is %s, expect {" % (iline,icol,orig[icol]))
@@ -279,11 +279,22 @@ def func_keyword_check(start, tokens, keywords):
279279
line_offsets[line] += len(toins)
280280
else:
281281
line_offsets[line] = len(toins)
282-
282+
283283

284284
f = open(filename + '.inst', 'w')
285285
f.write('#include "perfstubs_api/timer.h"\n')
286-
f.write('#ifdef __HIP_DEVICE_COMPILE__\n#undef PERFSTUBS_SCOPED_TIMER_FUNC\n#define PERFSTUBS_SCOPED_TIMER_FUNC()\n#endif\n')
286+
f.write('#if defined(__HIP_DEVICE_COMPILE__) || defined(__SYCL_DEVICE_ONLY__)\n#undef PERFSTUBS_SCOPED_TIMER_FUNC\n#define PERFSTUBS_SCOPED_TIMER_FUNC()\n#endif\n')
287+
f.write('''
288+
struct _ps_scoped_init{
289+
_ps_scoped_init(){
290+
PERFSTUBS_INITIALIZE();
291+
}
292+
~_ps_scoped_init(){
293+
PERFSTUBS_FINALIZE();
294+
}
295+
};
296+
#define PS_SCOPED_INIT() _ps_scoped_init ___ps_scoped_init
297+
''')
287298
for line in flines:
288299
f.write(line)
289300
f.close()

0 commit comments

Comments
 (0)