#include #include #include #include #include #include #define CHECK_CU_STATUS(STMT) \ do \ { \ CUresult status = (STMT); \ if (status != CUDA_SUCCESS) \ { \ const char *buffer; \ cuGetErrorName(status, &buffer); \ fmt::print("{}", buffer); \ } \ } while (0); class Engine { public: Engine(); ~Engine(); private: std::vector mThreads; static void workerThread(int id); }; class Worker { private: int id; VPIContext ctx; VPIStream stream; public: explicit Worker(int _id) noexcept : id(_id) { vpiContextCreate(VPI_BACKEND_CUDA, &ctx); vpiStreamCreate(VPI_BACKEND_CUDA, &stream); fmt::print("Worker {} Created\n", id); } ~Worker() { vpiStreamSync(stream); vpiStreamDestroy(stream); vpiContextDestroy(ctx); fmt::print("Worker {} Destroyed\n", id); } };