| 10 | } |
| 11 | |
| 12 | Adl2Wrapper::Adl2Wrapper() { |
| 13 | // get init proc, throw if not found |
| 14 | const auto adl2_main_control_create_ptr = |
| 15 | static_cast<int (*)(ADL_MAIN_MALLOC_CALLBACK, int, ADL_CONTEXT_HANDLE*)>( |
| 16 | dll.GetProcAddress("ADL2_Main_Control_Create")); |
| 17 | if (!adl2_main_control_create_ptr) { |
| 18 | throw std::runtime_error{ |
| 19 | "Failed to get main control create proc for amd"}; |
| 20 | } |
| 21 | |
| 22 | // get shutdown proc, but don't throw if not found (non-critical) |
| 23 | // TODO: log error if not found |
| 24 | ADL2_Main_Control_Destroy_ptr_ = static_cast<int (*)(ADL_CONTEXT_HANDLE)>( |
| 25 | dll.GetProcAddress("ADL2_Main_Control_Destroy")); |
| 26 | |
| 27 | // try and get all other procs, but don't throw if not found |
| 28 | // TODO: log error for any not found |
| 29 | #define X_(name, ...) p##name = static_cast<decltype(p##name)>(dll.GetProcAddress("ADL2_" #name)); |
| 30 | AMD_ADL2_ENDPOINT_LIST |
| 31 | #undef X_ |
| 32 | |
| 33 | // Initialize ADL2. The second parameter is 1, which means: |
| 34 | // retrieve adapter information only for adapters that are physically |
| 35 | // present and enabled in the system |
| 36 | if (!Ok(adl2_main_control_create_ptr(pwr::amd::ADL_Main_Memory_Alloc, 1, |
| 37 | &adl_context_))) { |
| 38 | throw std::runtime_error{"adl2 init call failed"}; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | Adl2Wrapper::~Adl2Wrapper() { |
| 43 | if (ADL2_Main_Control_Destroy_ptr_ && adl_context_) { |
nothing calls this directly
no test coverage detected