From 63d8de3bd381ff9bb852959f3ac1e7e261a8d48f Mon Sep 17 00:00:00 2001 From: Wenkai Du <43822138+wenkaidu@users.noreply.github.com> Date: Wed, 8 May 2024 07:00:25 -0700 Subject: [PATCH] Add compiler warning for uninitialized variable and fix (#1163) * Add compiler warning for uninitialized variable and fix * Add -Wsometimes-uninitialized * Convert warning to error [ROCm/rccl commit: b18784d8b8dda3eb2c45b0a710d1008e57c7be88] --- projects/rccl/CMakeLists.txt | 1 + projects/rccl/src/graph/xml.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/rccl/CMakeLists.txt b/projects/rccl/CMakeLists.txt index b04c3f8bd7..29f1404322 100644 --- a/projects/rccl/CMakeLists.txt +++ b/projects/rccl/CMakeLists.txt @@ -598,6 +598,7 @@ endif() ## Set RCCL compile options target_compile_options(rccl PRIVATE -parallel-jobs=12) +target_compile_options(rccl PRIVATE -Werror=uninitialized -Werror=sometimes-uninitialized) target_compile_options(rccl PRIVATE -Wno-format-nonliteral) target_compile_options(rccl PRIVATE -fgpu-rdc) # Generate relocatable device code (required for extern __shared__) target_compile_options(rccl PRIVATE -fvisibility=hidden) # Set symbol visibility to hidden by default diff --git a/projects/rccl/src/graph/xml.cc b/projects/rccl/src/graph/xml.cc index 770438e4fe..80c9a036e7 100644 --- a/projects/rccl/src/graph/xml.cc +++ b/projects/rccl/src/graph/xml.cc @@ -846,7 +846,7 @@ ncclResult_t ncclTopoFillGpu(struct ncclXml* xml, const char* busId, struct nccl NCCLCHECK(xmlSetAttrIfUnset(node, "class", "0x03")); NCCLCHECK(ncclTopoGetXmlFromSys(node, xml)); #if defined(__HIP_PLATFORM_AMD__) || defined(__HCC__) || defined(__HIPCC__) - uint32_t devIndex; + uint32_t devIndex = 0; static int rocmsmiInit = 0; if (rocmsmiInit == 0) { rocmsmiInit = (rocm_smi_init() != ncclSuccess) ? 2 : 1;