Files
xc-llm-ascend/csrc/vnpu_offload/shm_worker.h

36 lines
679 B
C
Raw Normal View History

2025-12-26 07:37:35 +00:00
#pragma once
2026-01-08 06:54:33 +00:00
#include <vector>
#include <atomic>
#include <thread>
2025-12-26 07:37:35 +00:00
#include "shm_helper.h"
2026-01-08 06:54:33 +00:00
2025-12-26 07:37:35 +00:00
class ShmWorker {
public:
ShmWorker();
~ShmWorker();
2026-01-08 06:54:33 +00:00
bool register_worker(int32_t tgid, int gpu_id, uint64_t *out_shareable_handle,
2025-12-26 07:37:35 +00:00
uint64_t *out_vmem_size);
2026-01-08 06:54:33 +00:00
bool try_lock_gpu(bool &out_self_hold);
bool lock_gpu(bool &out_self_hold);
2025-12-26 07:37:35 +00:00
void unlock_gpu();
private:
int32_t tgid;
2026-01-08 06:54:33 +00:00
int gpu_id;
2025-12-26 07:37:35 +00:00
ShmHelper *shm_helper;
std::thread heart_beat_thread;
std::atomic<bool> stop_heart_beat;
// request
uint64_t make_request(uint32_t type, uint64_t parameter);
int register_worker_shm();
// heart beat
void heart_beat_loop(int slot);
};