Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Importing external semaphore not working under linux #48

Open
Snektron opened this issue Oct 4, 2022 · 1 comment
Open

Importing external semaphore not working under linux #48

Snektron opened this issue Oct 4, 2022 · 1 comment

Comments

@Snektron
Copy link

Snektron commented Oct 4, 2022

Attempting to import an external semaphore always returns hipErrorInvalidValue under Linux:

#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 -oexternal_semaphore external_semaphore.hip
$ ./external_semaphore
error: hipErrorInvalidValue

Note: This is not caused by the external fd being incorrect, as the code path executed by hipDestroyExternalSemaphore hits NullDevice::importExtSemaphore:

$ gdb ./external_semaphore
$ b NullDevice::importExtSemaphore
$ r
Breakpoint 1 at 0x7ffff70d6da0: file /nix/store/v954yk0ng3hz50ppmf8ax1jfxhcfzgxq-rocclr-5.2.3/cmake/../device/rocm/rocdevice.hpp, line 237.

Here is a more complete example (but im not sure if its correct) that attempts to construct a proper semaphore fd:
external_semaphore.txt

$ hipcc -oexternal_semaphore ./external_semaphore.hip -I /usr/include/drm -ldrm
$ ./external_semaphore  /dev/dri/renderD128 
error: hipErrorInvalidValue
@pghafari
Copy link
Contributor

return value is been updated to hipNotSupported

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants