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
81 lines
2.1 KiB
C++
81 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <hip/hip_runtime.h>
|
|
#include <cstring>
|
|
#ifdef __linux__
|
|
#include <unistd.h>
|
|
#endif
|
|
#include <cstdio>
|
|
#include <map>
|
|
#include <sstream>
|
|
#include <vector>
|
|
#define COMMAND_LEN 256
|
|
#define BUFFER_LEN 512
|
|
|
|
#ifdef __linux__
|
|
int main(int argc, char** argv) {
|
|
if (argc < 0) {
|
|
return -1;
|
|
}
|
|
int testPassed = 0;
|
|
FILE* fpipe;
|
|
char command[COMMAND_LEN] = "";
|
|
const char* rocmInfo = "rocminfo";
|
|
|
|
snprintf(command, COMMAND_LEN, "%s", rocmInfo);
|
|
strncat(command, " | grep -i Uuid:", COMMAND_LEN);
|
|
// Execute the rocminfo command and extract the UUID info
|
|
fpipe = popen(command, "r");
|
|
if (fpipe == nullptr) {
|
|
printf("Unable to create command file\n");
|
|
return -1;
|
|
}
|
|
char command_op[BUFFER_LEN];
|
|
int j = 0;
|
|
std::map<int, std::vector<char>> uuid_map;
|
|
while (fgets(command_op, BUFFER_LEN, fpipe)) {
|
|
std::string rocminfo_line(command_op);
|
|
if (std::string::npos != rocminfo_line.find("CPU-")) {
|
|
continue;
|
|
} else if (auto loc = rocminfo_line.find("GPU-"); loc != std::string::npos) {
|
|
if (std::string::npos == rocminfo_line.find("GPU-XX")) {
|
|
std::vector<char> t_uuid(20, 0);
|
|
std::memcpy(t_uuid.data(), &rocminfo_line[loc], 20);
|
|
uuid_map[j] = t_uuid;
|
|
}
|
|
}
|
|
j++;
|
|
}
|
|
std::string s = argv[1];
|
|
std::string delimiter = ",";
|
|
size_t pos = 0;
|
|
std::vector<std::string> token;
|
|
while ((pos = s.find(delimiter)) != std::string::npos) {
|
|
token.push_back(s.substr(4, 16));
|
|
s.erase(0, pos + delimiter.length());
|
|
}
|
|
token.push_back(s.substr(4, 16));
|
|
int devCount = 0;
|
|
hipError_t localError;
|
|
localError = hipGetDeviceCount(&devCount);
|
|
if (localError == hipSuccess) {
|
|
printf("HIP Api returned hipSuccess");
|
|
}
|
|
for (int i = 0; i < devCount; i++) {
|
|
std::string uuid = token[i];
|
|
std::string mapVal(uuid_map[i].begin(), uuid_map[i].begin() + uuid_map[i].size());
|
|
if (memcmp(mapVal.substr(4, 16).c_str(), uuid.c_str(), 16) == 0) {
|
|
testPassed += 1;
|
|
}
|
|
}
|
|
if (testPassed == devCount) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
#endif
|