ROCm / hipamd

35 stars 37 forks source link

Missing definitions for hipExternalSemaphore and hipExternalMemory when compiling for cuda #49

Open Snektron opened 1 year ago

Snektron commented 1 year ago

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.

Snektron commented 1 year ago

hipGraphics symbols are also missing