diff --git a/Jenkinsfile b/Jenkinsfile index 42f8b67c3c..526a825c65 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -119,7 +119,7 @@ def docker_build_inside_image( def build_image, String inside_args, String platf cd ${build_dir_rel} make install -j\$(nproc) make build_tests -j\$(nproc) - ctest -E hipEnvVarDriver + make test """ // If unit tests output a junit or xunit file in the future, jenkins can parse that file // to display test results on the dashboard diff --git a/tests/src/hipEnvVar.cpp b/tests/src/hipEnvVar.cpp index d5942518e0..ff68103816 100644 --- a/tests/src/hipEnvVar.cpp +++ b/tests/src/hipEnvVar.cpp @@ -109,15 +109,14 @@ int main(int argc, char **argv) std::cout << devCount << std::endl; } if (retDevInfo) { - hipSetDevice(device); - hipDeviceProp_t devProp; + hipDevice_t deviceT; + hipDeviceGet(&deviceT, device); - hipGetDeviceProperties(&devProp, device); - if (devProp.major < 1) { - printf("%d does not support HIP\n", device); - return -1; - } - std::cout << devProp.pciBusID << std::endl; + char pciBusId[100]; + memset(pciBusId,0,100); + hipDeviceGetPCIBusId(pciBusId,100,deviceT); + + cout< #include #include "hip/hip_runtime.h" +#include +#include using namespace std; int getDeviceNumber(){ - FILE *in; - char buff[512]; - string str; - if(!(in = popen("./hipEnvVar -c", "r"))){ - return 1; + FILE *in; + char buff[512]; + string str; + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + if(!(in = popen("./directed_tests/hipEnvVar -c", "r"))){ + return 1; + } + while(fgets(buff, 512, in)!=NULL){ + cout << buff; } - fgets(buff, sizeof(buff), in); pclose(in); return atoi(buff); } // Query the current device ID remotely to hipEnvVar -int getDevicePCIBusNumRemote(int deviceID){ +void getDevicePCIBusNumRemote(int deviceID, char* pciBusID){ FILE *in; - char buff[512]; - string str = "./hipEnvVar -d "; + string str = "./directed_tests/hipEnvVar -d "; str += std::to_string(deviceID); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); if(!(in = popen(str.c_str(), "r"))){ - return 1; + exit(1); + } + while(fgets(pciBusID, 100, in)!=NULL){ + cout << pciBusID; } - fgets(buff, sizeof(buff), in); pclose(in); - return atoi(buff); } -// Query the current device ID locally -int getDevicePCIBusNum(int deviceID){ - hipSetDevice(deviceID); - hipDeviceProp_t devProp; +// Query the current device ID locally on AMD path +void getDevicePCIBusNum(int deviceID, char* pciBusID){ + hipDevice_t deviceT; + hipDeviceGet(&deviceT, deviceID); - hipGetDeviceProperties(&devProp, deviceID); - if (devProp.major < 1) { - printf("%d does not support HIP\n", deviceID); - return -1; - } - return devProp.pciBusID; + memset(pciBusID,0,100); + hipDeviceGetPCIBusId(pciBusID,100,deviceT); } int main() { unsetenv("HIP_VISIBLE_DEVICES"); unsetenv("CUDA_VISIBLE_DEVICES"); + + std::vector devPCINum; + char pciBusID[100]; //collect the device pci bus ID for all devices int totalDeviceNum = getDeviceNumber(); std::cout << "The total number of available devices is " << totalDeviceNum<< std::endl <<"Valid index range is 0 - "< devPCINum; for (int i = 0; i < totalDeviceNum ; i++) { - devPCINum.push_back(getDevicePCIBusNum(i)); + getDevicePCIBusNum(i, pciBusID); + devPCINum.push_back(pciBusID); std::cout <<"The collected device PCI Bus ID of Device "<