Open jdgh000 opened 8 months ago
Hello,
Can you please try to replace
#include <roctracer_ext.h>
with
#include <roctracer/roctracer_ext.h>
Also, use the following to compile:
hipcc -I/opt/rocm-5.7.0/include -L/opt/rocm-5.7.0/lib -lroctracer64 <filename.cpp>
?
Please let me know if this works for you.
Ok, that worked, thanks for assistance on this one. However, how would one use it to tracing to be captured on start/stop? I used "rocprof --hip-trace ./a.out" and resulting json has two entries of kernel(add() and also hipmemcpy. Was expecting only 2nd call to add will be captured...
egrep -irn add
3:#include <roctracer/roctracer_ext.h>
18:__global__ void add( int * a, int * b, int * c ) {
67: hipLaunchKernelGGL(add, blocks, threadsPerBlock, 0, 0, dev_a, dev_b, dev_c);
71: roctracer_start();
72: hipLaunchKernelGGL(add, blocks, threadsPerBlock, 0, 0, dev_a, dev_b, dev_c);
74: roctracer_stop();
75: hipLaunchKernelGGL(add, blocks, threadsPerBlock, 0, 0, dev_a, dev_b, dev_c);
76: //add<<<blocks, threadsPerBlock>>>(dev_a, dev_b, dev_c);
[root@localhost ex-1]# egrep -irn "kernel.*add" results.json
161: "args":"( kernel(add(int*, int*, int*)) function_address(0x562bb6ce5d90) numBlocks({z(1) y(1) x(15}) dimBlocks({z(1) y(1) x(256}) args(0x7ffc3b35f040) sharedMemBytes(0) stream(1))",
197: "args":"( kernel(add(int*, int*, int*)) function_address(0x562bb6ce5d90) numBlocks({z(1) y(1) x(15}) dimBlocks({z(1) y(1) x(256}) args(0x7ffc3b35f040) sharedMemBytes(0) stream(1))",
[root@localhost ex-1]# nano -w results.json
[root@localhost ex-1]# egrep -irn "hipmemcpy" results.
grep: results.: No such file or directory
[root@localhost ex-1]# egrep -irn "hipmemcpy" results.json
94:,{"ph":"X","name":"hipMemcpy","pid":"2","tid":"795","ts":"31035794492","dur":"184178",
100: "Name":"hipMemcpy",
106:,{"ph":"X","name":"hipMemcpy","pid":"2","tid":"795","ts":"31035978679","dur":"17",
112: "Name":"hipMemcpy",
118:,{"ph":"X","name":"hipMemcpy","pid":"2","tid":"795","ts":"31035978696","dur":"14",
124: "Name":"hipMemcpy",
You will need to use '--trace-start off' option in rocprof along with the roctracer_start() and roctracer_stop() in your application as you already have.
OK, that appears to work, as well as roctx. Thanks.
One more question, can python use those apis? So far, i see mostly C++ codes, assuming no support for python.
For roctx, it should be working using python C libraries that can be used to call C/C++ functions inside python code. But I can't 100% confirm that for roctracer API calls.
Following simple vector c++ without tracer code support will compile and run ok: hipcc ; ./a.out
if I add roctracer_ext.h include and compile with roctracer library, bunch of errors spit out: hipcc -I /opt/rocm-5.7.0/roctracer/include/ /opt/rocm-5.7.0/lib/libroctracer64.so
error log with compile with roctracer support:
example vector add code: