CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
112 lines
4.1 KiB
C
112 lines
4.1 KiB
C
/*
|
|
* Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <dlfcn.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <hsakmt.h>
|
|
|
|
HSAKMT_STATUS HSAKMTAPI (*pfn_hsaKmtOpenKFD)(void);
|
|
HSAKMT_STATUS HSAKMTAPI (*pfn_hsaKmtCloseKFD)(void);
|
|
HSAKMT_STATUS HSAKMTAPI (*pfn_hsaKmtGetVersion)(HsaVersionInfo* VersionInfo);
|
|
HSAKMT_STATUS HSAKMTAPI (*pfn_hsaKmtAcquireSystemProperties)(HsaSystemProperties* SystemProperties);
|
|
HSAKMT_STATUS HSAKMTAPI (*pfn_hsaKmtReleaseSystemProperties)(void);
|
|
|
|
HsaVersionInfo g_versionInfo;
|
|
HsaSystemProperties g_systemProperties;
|
|
|
|
static void hsa_perror(const char *s, HSAKMT_STATUS status)
|
|
{
|
|
static const char *errorStrings[] = {
|
|
[HSAKMT_STATUS_SUCCESS] = "Success",
|
|
[HSAKMT_STATUS_ERROR] = "General error",
|
|
[HSAKMT_STATUS_DRIVER_MISMATCH] = "Driver mismatch",
|
|
[HSAKMT_STATUS_INVALID_PARAMETER] = "Invalid parameter",
|
|
[HSAKMT_STATUS_INVALID_HANDLE] = "Invalid handle",
|
|
[HSAKMT_STATUS_INVALID_NODE_UNIT] = "Invalid node or unit",
|
|
[HSAKMT_STATUS_NO_MEMORY] = "No memory",
|
|
[HSAKMT_STATUS_BUFFER_TOO_SMALL] = "Buffer too small",
|
|
[HSAKMT_STATUS_NOT_IMPLEMENTED] = "Not implemented",
|
|
[HSAKMT_STATUS_NOT_SUPPORTED] = "Not supported",
|
|
[HSAKMT_STATUS_UNAVAILABLE] = "Unavailable",
|
|
[HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED] = "Kernel IO channel not opened",
|
|
[HSAKMT_STATUS_KERNEL_COMMUNICATION_ERROR] = "Kernel communication error",
|
|
[HSAKMT_STATUS_KERNEL_ALREADY_OPENED] = "Kernel already opened",
|
|
[HSAKMT_STATUS_HSAMMU_UNAVAILABLE] = "HSA MMU unavailable",
|
|
[HSAKMT_STATUS_WAIT_FAILURE] = "Wait failure",
|
|
[HSAKMT_STATUS_WAIT_TIMEOUT] = "Wait timeout",
|
|
[HSAKMT_STATUS_MEMORY_ALREADY_REGISTERED] = "Memory already registered",
|
|
[HSAKMT_STATUS_MEMORY_NOT_REGISTERED] = "Memory not registered",
|
|
[HSAKMT_STATUS_MEMORY_ALIGNMENT] = "Memory alignment error"
|
|
};
|
|
|
|
if (status >= 0 && status <= HSAKMT_STATUS_MEMORY_ALIGNMENT)
|
|
fprintf(stderr, "%s: %s\n", s, errorStrings[status]);
|
|
else
|
|
fprintf(stderr, "%s: Unknown error %d\n", s, status);
|
|
}
|
|
|
|
#define HSA_CHECK_RETURN(call) do { \
|
|
HSAKMT_STATUS __ret; \
|
|
printf(" Calling %s\n", #call); \
|
|
__ret = pfn_##call; \
|
|
if (__ret != HSAKMT_STATUS_SUCCESS) { \
|
|
hsa_perror(#call, __ret); \
|
|
return __ret; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define HSA_DLSYM(handle, func) do { \
|
|
pfn_##func = dlsym(handle, #func); \
|
|
if (pfn_##func == NULL) { \
|
|
fprintf(stderr, "dlsym failed: %s\n", dlerror()); \
|
|
return HSAKMT_STATUS_ERROR; \
|
|
} \
|
|
} while(0)
|
|
|
|
static int runTest(void *handle)
|
|
{
|
|
HSA_DLSYM(handle, hsaKmtOpenKFD);
|
|
HSA_DLSYM(handle, hsaKmtCloseKFD);
|
|
HSA_DLSYM(handle, hsaKmtGetVersion);
|
|
HSA_DLSYM(handle, hsaKmtAcquireSystemProperties);
|
|
HSA_DLSYM(handle, hsaKmtReleaseSystemProperties);
|
|
|
|
HSA_CHECK_RETURN(hsaKmtOpenKFD());
|
|
HSA_CHECK_RETURN(hsaKmtGetVersion(&g_versionInfo));
|
|
HSA_CHECK_RETURN(hsaKmtAcquireSystemProperties(&g_systemProperties));
|
|
|
|
HSA_CHECK_RETURN(hsaKmtReleaseSystemProperties());
|
|
HSA_CHECK_RETURN(hsaKmtCloseKFD());
|
|
|
|
return HSAKMT_STATUS_SUCCESS;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
void *handle;
|
|
int i;
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
printf("Iteration %d:\n Loading libhsakmt.so\n", i+1);
|
|
|
|
handle = dlopen("libhsakmt.so", RTLD_LAZY);
|
|
if (handle == NULL) {
|
|
fprintf(stderr, "dlopen failed: %s\n", dlerror());
|
|
exit(1);
|
|
}
|
|
|
|
if (runTest(handle) != HSAKMT_STATUS_SUCCESS)
|
|
exit(1);
|
|
|
|
printf(" Unloading libhsakmt.so\n");
|
|
if (dlclose(handle) != 0) {
|
|
fprintf(stderr, "dlclose failed: %s\n", dlerror());
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|