hipamd
hipamd copied to clipboard
Missing definitions for hipExternalSemaphore and hipExternalMemory when compiling for cuda
When compiling the following executable for cuda, hipcc/nvcc reports errors about hipExternalSemaphore_t and the related functions type not being defined:
#include <hip/hip_runtime.h>
#include <iostream>
#include <cstdlib>
int main(int argc, char* argv[]) {
hipExternalSemaphoreHandleDesc desc = {};
desc.type = hipExternalSemaphoreHandleTypeOpaqueFd;
desc.handle.fd = 0;
hipExternalSemaphore_t external_sem;
hipError_t result = hipImportExternalSemaphore(&external_sem, &desc);
if (result != hipSuccess) {
std::cerr << "error: " << hipGetErrorString(result) << std::endl;
return EXIT_FAILURE;
}
std::cout << "success" << std::endl;
hipDestroyExternalSemaphore(external_sem);
return EXIT_SUCCESS;
}
$ hipcc -o external_semaphore ./external_semaphore.hip -x cu
./external_semaphore.hip(6): error: identifier "hipExternalSemaphoreHandleDesc" is undefined
./external_semaphore.hip(7): error: identifier "hipExternalSemaphoreHandleTypeOpaqueFd" is undefined
./external_semaphore.hip(10): error: identifier "hipExternalSemaphore_t" is undefined
./external_semaphore.hip(11): error: identifier "hipImportExternalSemaphore" is undefined
./external_semaphore.hip(19): error: identifier "hipDestroyExternalSemaphore" is undefined
./external_semaphore.hip(21): error: identifier "hipExternalMemory_t" is undefined
This is also the case for hipExternalMemory_t and related types/functions.
Judging from the headers, it seems like the definitions for this are simply missing. For amd, they are defined in hip_runtime_api.h, but guarded by a macro that checks for amd. If that same if statement determines that the compilation is for nvidia, nvidia_hip_runtime_api.h is included, and the relevant definitions are missing there.
hipGraphics symbols are also missing