-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhip_tools.cpp
More file actions
61 lines (44 loc) · 1.09 KB
/
hip_tools.cpp
File metadata and controls
61 lines (44 loc) · 1.09 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
#include <stdio.h>
#include <iostream>
#include <roctx.h>
#include <roctracer_ext.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(){
roctracer_start();
}
void stop_roctracer(){
roctracer_stop();
}
int roctxr_start( char *c){
// std::cout << "Starting roctx marker: " << c << std::endl;
int id = roctxRangeStart(c);
return id;
}
void roctxr_stop( int id){
roctxRangeStop(id);
}
void roctxr_push( char *c){
roctxRangePush(c);
}
void roctxr_pop(){
roctxRangePop();
}
}