forked from bvillasen/python_roctx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhip_tools.cpp
More file actions
68 lines (48 loc) · 1.17 KB
/
hip_tools.cpp
File metadata and controls
68 lines (48 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <iostream>
#include <rocprofiler-sdk-roctx/roctx.h>
#include <hip/hip_runtime.h>
#define CHECK(command) { \
hipError_t status = command; \
if (status!=hipSuccess) { \
std::cout << "Error: HIP reports " << hipGetErrorString(status) << std::endl; \
std::abort(); }}
extern "C" {
int set_device( int proc_id ) {
int n_devices;
CHECK( hipGetDeviceCount(&n_devices) );
if (n_devices == 0){
std::cout << "MPI rank= " << proc_id << " NO DEVICES FOUND!" << std::endl;
return 0;
}
int device = proc_id % n_devices;
CHECK( hipSetDevice(device) );
std::cout << "MPI rank= " << proc_id << " will use GPU ID " << device << " / " << n_devices << std::endl;
return device;
}
void start_roctracer(int tid){
roctxProfilerResume(tid);
//roctracer_start();
}
int get_roctx_tid(){
auto tid = roctx_thread_id_t{};
roctxGetThreadId(&tid);
return tid;
}
void stop_roctracer(int tid){
roctxProfilerPause(tid);
}
int roctxr_start( char *c){
int id = roctxRangeStart(c);
return id;
}
void roctxr_stop( int id){
roctxRangeStop(id);
}
void roctxr_push( char *c){
roctxRangePush(c);
}
void roctxr_pop(){
roctxRangePop();
}
}