From 58b18e5e4373273784514b138ff471434be18a8e Mon Sep 17 00:00:00 2001 From: arjun-raj-kuppala <60718144+arjun-raj-kuppala@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:57:43 +0530 Subject: [PATCH 1/5] Enable CI for HIPCC --- amd/hipcc/.jenkins/Jenkinsfile | 110 +++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 amd/hipcc/.jenkins/Jenkinsfile diff --git a/amd/hipcc/.jenkins/Jenkinsfile b/amd/hipcc/.jenkins/Jenkinsfile new file mode 100644 index 00000000000000..a785c95a496169 --- /dev/null +++ b/amd/hipcc/.jenkins/Jenkinsfile @@ -0,0 +1,110 @@ +def hipBuildTest(String backendLabel) { + node(backendLabel) { + stage("Source sync ${backendLabel}") { + + // Checkout hip repository with the PR patch + dir("${WORKSPACE}/HIPCC") { + checkout scm + env.HIPCC_DIR = "${WORKSPACE}" + "/HIPCC" + } + + // Clone HIP repository + dir("${WORKSPACE}/hip") { + git branch: 'develop', + url: 'https://github.com/ROCm-Developer-Tools/HIP' + env.HIP_DIR = "${WORKSPACE}" + "/hip" + } + + // Clone hipamd repository + dir("${WORKSPACE}/hipamd") { + git branch: 'develop', + url: 'https://github.com/ROCm-Developer-Tools/hipamd' + } + + // Clone vdi and opencl for only amd backend server + if (backendLabel =~ /.*amd.*/) { + dir("${WORKSPACE}/ROCm-OpenCL-Runtime") { + git branch:'develop', + url: 'https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime' + env.OPENCL_DIR = "${WORKSPACE}" + "/ROCm-OpenCL-Runtime" + } + dir("${WORKSPACE}/ROCclr") { + git branch:'develop', + url: 'https://github.com/ROCm-Developer-Tools/ROCclr' + env.ROCclr_DIR = "${WORKSPACE}" + "/ROCclr" + } + } + } + + stage("Build - HIPCC") { + // Running the build on HIPCC workspace + dir("${WORKSPACE}/HIPCC") { + sh """#!/usr/bin/env bash + set -x + rm -rf build + mkdir build + cd build/ + cmake .. + make + """ + } + } + + stage("Build - Catch2 framework") { + // Running the build on hipamd workspace + dir("${WORKSPACE}/hipamd") { + sh """#!/usr/bin/env bash + set -x + mkdir -p build + cd build + # Check if backend label contains string "amd" or backend host is a server with amd gpu + if [[ $backendLabel =~ amd ]]; then + cmake -DHIP_CATCH_TEST=1 -DHIP_PATH=\$PWD/install -DHIPCC_BIN_DIR=\$HIPCC_DIR/build -DHIP_COMMON_DIR=\$HIP_DIR -DAMD_OPENCL_PATH=\$OPENCL_DIR -DROCCLR_PATH=\$ROCclr_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + else + export HIP_PLATFORM=nvidia + export HIP_COMPILER=nvcc + export HIP_RUNTIME=cuda + cmake -DHIP_CATCH_TEST=1 -DHIP_PATH=\$PWD/install -DHIPCC_BIN_DIR=\$HIPCC_DIR/build -DHIP_COMMON_DIR=$HIP_DIR -DCMAKE_INSTALL_PREFIX=\$PWD/install .. + fi + make install -j\$(nproc) + if [[ $backendLabel =~ amd ]]; then + make build_tests -j\$(nproc) + else + HIP_COMPILER=nvcc HIP_PLATFORM=nvidia make build_tests -j\$(nproc) + fi + """ + } + } + + stage('HIP Unit Tests - Catch2 framework') { + dir("${WORKSPACE}/hipamd/build") { + sh """#!/usr/bin/env bash + set -x + # Check if backend label contains string "amd" or backend host is a server with amd gpu + if [[ $backendLabel =~ amd ]]; then + LLVM_PATH=/opt/rocm/llvm ctest -E 'Unit_hiprtc_saxpy' + else + make test + fi + """ + } + } + } +} + +timestamps { + node('external-bootstrap') { + skipDefaultCheckout() + + // labels belonging to each backend - AMD, NVIDIA + String[] labels = ['hip-amd-vg20-ubu1804', 'hip-nvidia-rtx5000-ubu1804'] + buildMap = [:] + + labels.each { backendLabel -> + echo "backendLabel: ${backendLabel}" + buildMap[backendLabel] = { hipBuildTest(backendLabel) } + } + buildMap['failFast'] = false + parallel buildMap + } +} From 92a2f08eb23536215be3a8880fe7ce4cfea95768 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Thu, 24 Feb 2022 13:43:36 -0500 Subject: [PATCH 2/5] Stop passing --fhip-new-launch-api to Clang Change-Id: I344d56d2e4584281d5eccbf8ab8dc1c0576b2d30 --- amd/hipcc/src/hipBin_amd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/amd/hipcc/src/hipBin_amd.h b/amd/hipcc/src/hipBin_amd.h index d5a80f05aa90f4..ac3aecb087e1aa 100644 --- a/amd/hipcc/src/hipBin_amd.h +++ b/amd/hipcc/src/hipBin_amd.h @@ -1093,7 +1093,6 @@ void HipBinAmd::executeHipCCCmd(vector argv) { + deviceLibPath + "\""; HIPCXXFLAGS += hip_device_lib_str; } - HIPCXXFLAGS += " -fhip-new-launch-api"; } if (os != windows) { HIPLDFLAGS += " -lgcc_s -lgcc -lpthread -lm -lrt"; From c9ae736d9ba086b9bf6d059f2d13efb2f3ae1178 Mon Sep 17 00:00:00 2001 From: Ajay Date: Wed, 16 Mar 2022 18:34:54 +0000 Subject: [PATCH 3/5] SWDEV-326661 - device_lib_path, return error code when build fails Change-Id: Idca31dedf3b5ce1524fc344a47a3c96afde562ad --- amd/hipcc/src/hipBin.cpp | 1 + amd/hipcc/src/hipBin_amd.h | 18 +++--------------- amd/hipcc/src/hipBin_nvidia.h | 16 ++-------------- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/amd/hipcc/src/hipBin.cpp b/amd/hipcc/src/hipBin.cpp index 3e196e62c5b339..dfbc35068fa276 100644 --- a/amd/hipcc/src/hipBin.cpp +++ b/amd/hipcc/src/hipBin.cpp @@ -112,6 +112,7 @@ void HipBin::executeHipBin(string filename, int argc, char* argv[]) { cout << "Command " << filename << " not supported. Name the exe as hipconfig" << " or hipcc and then try again ..." << endl; + exit(-1); } } diff --git a/amd/hipcc/src/hipBin_amd.h b/amd/hipcc/src/hipBin_amd.h index ac3aecb087e1aa..2164e2750ad810 100644 --- a/amd/hipcc/src/hipBin_amd.h +++ b/amd/hipcc/src/hipBin_amd.h @@ -359,12 +359,12 @@ string HipBinAmd::getCppConfig() { } string HipBinAmd::getDeviceLibPath() const { - string deviceLibPath; const EnvVariables& var = getEnvVariables(); const string& rocclrHomePath = getRocclrHomePath(); const string& roccmPath = getRoccmPath(); fs::path bitCodePath = rocclrHomePath; bitCodePath /= "lib/bitcode"; + string deviceLibPath = var.deviceLibPathEnv_; if (var.deviceLibPathEnv_.empty() && fs::exists(bitCodePath)) { deviceLibPath = bitCodePath.string(); } @@ -1160,20 +1160,8 @@ void HipBinAmd::executeHipCCCmd(vector argv) { sysOut = hipBinUtilPtr_->exec(CMD.c_str(), true); string cmdOut = sysOut.out; int CMD_EXIT_CODE = sysOut.exitCode; - if (CMD_EXIT_CODE == -1) { - cout << "failed to execute: $!\n"; - } else if (CMD_EXIT_CODE & 127) { - string childOut; - int childCode; - (CMD_EXIT_CODE & 127), (CMD_EXIT_CODE & 128) ? - childOut = "with" : childOut = "without"; - (CMD_EXIT_CODE & 127), (CMD_EXIT_CODE & 128) ? - childCode = (CMD_EXIT_CODE & 127) : - childCode = (CMD_EXIT_CODE & 128); - cout << "child died with signal " << childCode << "," << childOut << - " coredump "<< " for cmd: " << CMD << endl; - } else { - CMD_EXIT_CODE = CMD_EXIT_CODE >> 8; + if (CMD_EXIT_CODE !=0) { + cout << "failed to execute:" << CMD << std::endl; } exit(CMD_EXIT_CODE); } // end of runCmd section diff --git a/amd/hipcc/src/hipBin_nvidia.h b/amd/hipcc/src/hipBin_nvidia.h index 7a161fd901b2b3..6feb3150287019 100644 --- a/amd/hipcc/src/hipBin_nvidia.h +++ b/amd/hipcc/src/hipBin_nvidia.h @@ -591,20 +591,8 @@ void HipBinNvidia::executeHipCCCmd(vector argv) { sysOut = hipBinUtilPtr_->exec(CMD.c_str(), true); string cmdOut = sysOut.out; int CMD_EXIT_CODE = sysOut.exitCode; - if (CMD_EXIT_CODE == -1) { - cout << "failed to execute: $!\n"; - } else if (CMD_EXIT_CODE & 127) { - string childOut; - int childCode; - (CMD_EXIT_CODE & 127), (CMD_EXIT_CODE & 128) ? - childOut = "with" : childOut = "without"; - (CMD_EXIT_CODE & 127), (CMD_EXIT_CODE & 128) ? - childCode = (CMD_EXIT_CODE & 127) : - childCode = (CMD_EXIT_CODE & 128); - cout << "child died with signal " << childCode << "," << - childOut << " coredump "<< " for cmd: " << CMD << endl; - } else { - CMD_EXIT_CODE = CMD_EXIT_CODE >> 8; + if (CMD_EXIT_CODE !=0) { + cout << "failed to execute:" << CMD << std::endl; } exit(CMD_EXIT_CODE); } From a40db814c943d9746375aa786ddd17dd3c93ff58 Mon Sep 17 00:00:00 2001 From: Ajay Date: Fri, 18 Mar 2022 18:14:38 +0000 Subject: [PATCH 4/5] SWDEV-326661 - devicelib path fix --- amd/hipcc/src/hipBin_amd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/hipcc/src/hipBin_amd.h b/amd/hipcc/src/hipBin_amd.h index 2164e2750ad810..bf928cfff15271 100644 --- a/amd/hipcc/src/hipBin_amd.h +++ b/amd/hipcc/src/hipBin_amd.h @@ -365,7 +365,7 @@ string HipBinAmd::getDeviceLibPath() const { fs::path bitCodePath = rocclrHomePath; bitCodePath /= "lib/bitcode"; string deviceLibPath = var.deviceLibPathEnv_; - if (var.deviceLibPathEnv_.empty() && fs::exists(bitCodePath)) { + if (deviceLibPath.empty() && fs::exists(bitCodePath)) { deviceLibPath = bitCodePath.string(); } From 5cef32d8ded69db8f1890d9396f83714b8def0d9 Mon Sep 17 00:00:00 2001 From: Mark Searles Date: Wed, 20 Jul 2022 12:26:32 -0700 Subject: [PATCH 5/5] Remove code that sets -std and -fms-* flags Code was a workaround; no longer needed; rely instead on the clang defaults. --- amd/hipcc/src/hipBin_amd.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/amd/hipcc/src/hipBin_amd.h b/amd/hipcc/src/hipBin_amd.h index bf928cfff15271..f94e4a59a59f05 100644 --- a/amd/hipcc/src/hipBin_amd.h +++ b/amd/hipcc/src/hipBin_amd.h @@ -203,11 +203,6 @@ string HipBinAmd::getHipInclude() const { void HipBinAmd::initializeHipCXXFlags() { string hipCXXFlags; const OsType& os = getOSInfo(); - if (os == windows) { - hipCXXFlags = " -std=c++14 -fms-extensions -fms-compatibility"; - } else { - hipCXXFlags = " -std=c++11"; - } string hipClangIncludePath; hipClangIncludePath = getCompilerIncludePath(); hipCXXFlags += " -isystem \"" + hipClangIncludePath;