Files
rocm-systems/src/core/proxy_queue.h
T

56 lines
1.8 KiB
C++
Raw Normal View History

2017-11-09 17:26:19 -06:00
#ifndef _SRC_CORE_PROXY_QUEUE_H
#define _SRC_CORE_PROXY_QUEUE_H
#include <hsa.h>
#include <hsa_api_trace.h>
#include <atomic>
#include <map>
#include <mutex>
#include "core/queue.h"
#include "core/types.h"
struct HsaApiTable;
namespace rocprofiler {
typedef void (*hsa_amd_queue_intercept_packet_writer)(const void* packets, uint64_t count);
2017-11-29 13:53:12 -06:00
typedef void (*on_submit_cb_t)(const void* packet, uint64_t count, uint64_t que_idx, void* data,
hsa_amd_queue_intercept_packet_writer writer);
2017-11-09 17:26:19 -06:00
class ProxyQueue : public Queue {
2017-11-29 13:53:12 -06:00
public:
2017-11-09 17:26:19 -06:00
static void InitFactory() {
const char* type = getenv("ROCP_PROXY_QUEUE");
if (type != NULL) {
if (strncmp(type, "rocp", 4) == 0) rocp_type_ = true;
}
}
static void HsaIntercept(HsaApiTable* table);
2017-11-29 13:53:12 -06:00
static ProxyQueue* Create(hsa_agent_t agent, uint32_t size, hsa_queue_type32_t type,
void (*callback)(hsa_status_t status, hsa_queue_t* source, void* data),
void* data, uint32_t private_segment_size, uint32_t group_segment_size,
hsa_queue_t** queue, hsa_status_t* status);
2017-11-09 17:26:19 -06:00
static hsa_status_t Destroy(const ProxyQueue* obj);
2017-11-29 13:53:12 -06:00
virtual hsa_status_t Init(hsa_agent_t agent, uint32_t size, hsa_queue_type32_t type,
void (*callback)(hsa_status_t status, hsa_queue_t* source, void* data),
void* data, uint32_t private_segment_size, uint32_t group_segment_size,
hsa_queue_t** queue) = 0;
2017-11-09 17:26:19 -06:00
virtual hsa_status_t Cleanup() const = 0;
virtual hsa_status_t SetInterceptCB(on_submit_cb_t on_submit_cb, void* data) = 0;
virtual void Submit(const packet_t* packet) = 0;
2017-11-29 13:53:12 -06:00
protected:
virtual ~ProxyQueue(){};
2017-11-09 17:26:19 -06:00
2017-11-29 13:53:12 -06:00
private:
2017-11-09 17:26:19 -06:00
static bool rocp_type_;
};
2017-11-29 13:53:12 -06:00
} // namespace rocprofiler
2017-11-09 17:26:19 -06:00
2017-11-29 13:53:12 -06:00
#endif // _SRC_CORE_PROXY_QUEUE_H