roctracer_wrapper.cpp 1.35 KB
Newer Older
wangkaixiong's avatar
init  
wangkaixiong committed
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
#include "roctracer_wrapper.h"
#include "hip/hip_runtime.h"
#include "roctracer/roctx.h"
#include <iostream>
#include <sstream>

class RoctracerWrapper::Impl {
public:
    Impl() {
        // 初始化HIP
        hipError_t err = hipInit(0);
        if (err != hipSuccess) {
            std::cerr << "Failed to initialize HIP: " << hipGetErrorString(err) << std::endl;
        }
    }
    
    ~Impl() {
        // 清理资源
    }
    
    void mark(const std::string& message) {
        roctxMark(message.c_str());
    }
    
    int rangeStart(const std::string& message) {
        return roctxRangeStart(message.c_str());
    }
    
    void rangePush(const std::string& message) {
        roctxRangePush(message.c_str());
    }
    
    void rangePop() {
        roctxRangePop();
    }
    
    void rangeStop(int id) {
        roctxRangeStop(id);
    }
    
};

RoctracerWrapper::RoctracerWrapper() : impl(std::make_unique<Impl>()) {}
RoctracerWrapper::~RoctracerWrapper() = default;

void RoctracerWrapper::mark(const std::string& message) { impl->mark(message); }
int RoctracerWrapper::rangeStart(const std::string& message) { return impl->rangeStart(message); }
void RoctracerWrapper::rangePush(const std::string& message) { impl->rangePush(message); }
void RoctracerWrapper::rangePop() { impl->rangePop(); }
void RoctracerWrapper::rangeStop(int id) { impl->rangeStop(id); }