Skip to content

Commit 444077a

Browse files
doru1004carlobertolli
authored andcommitted
[libomptarget] Fix unified shared memory testing with check-openmp.
This patch fixes the following issues: - AOMP_GPU no longer needed to be specified - correctly set architecture list which enabled unified memory support to be detected for AMD architectures - add ability to select which architecture to use based on the ROCR_VISIBLE_DEVICES value for systems with multiple AMD GPU types - remove additional entry for force-usm compilation - fix the current force-usm compilation entry to pass the correct compiler flags to specify the architecture - remove force_usm.h header file that's no longer needed - remove inclusion of the force_usm.h file in the compile line Change-Id: Id7ff15178bc2eab5aae583dda97c911cccd178d5
1 parent 1ff264d commit 444077a

File tree

5 files changed

+16
-33
lines changed

5 files changed

+16
-33
lines changed

clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -564,15 +564,6 @@ void AMDGPUOpenMPToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
564564
SmallString<128> P(HostTC.getDriver().ResourceDir);
565565
llvm::sys::path::append(P, "include/cuda_wrappers");
566566
CC1Args.push_back(DriverArgs.MakeArgString(P));
567-
568-
// Force APU mode will focefully include #pragma omp requires
569-
// unified_shared_memory via the force_usm header
570-
if (DriverArgs.hasArg(options::OPT_fopenmp_force_usm)) {
571-
CC1Args.push_back("-include");
572-
CC1Args.push_back(
573-
DriverArgs.MakeArgString(HostTC.getDriver().ResourceDir +
574-
"/include/openmp_wrappers/force_usm.h"));
575-
}
576567
}
577568

578569
/// Convert path list to Fortran frontend argument

clang/lib/Headers/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ set(openmp_wrapper_files
324324
openmp_wrappers/complex_cmath.h
325325
openmp_wrappers/new
326326
openmp_wrappers/hip/hip_runtime.h
327-
openmp_wrappers/usm/force_usm.h
328327
)
329328

330329
set(llvm_libc_wrapper_files

clang/lib/Headers/openmp_wrappers/usm/force_usm.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ if(LIBOMPTARGET_AMDGPU_ARCH)
101101
execute_process(COMMAND ${LIBOMPTARGET_AMDGPU_ARCH}
102102
OUTPUT_VARIABLE LIBOMPTARGET_AMDGPU_ARCH_OUTPUT
103103
OUTPUT_STRIP_TRAILING_WHITESPACE)
104-
string(FIND "${LIBOMPTARGET_AMDGPU_ARCH_OUTPUT}" "\n" first_arch_string)
105-
string(SUBSTRING "${LIBOMPTARGET_AMDGPU_ARCH_OUTPUT}" 0 ${first_arch_string}
106-
arch_string)
107-
if(arch_string)
104+
string(REPLACE "\n" ";" amdgpu_arch_list "${LIBOMPTARGET_AMDGPU_ARCH_OUTPUT}")
105+
if(amdgpu_arch_list)
108106
set(LIBOMPTARGET_FOUND_AMDGPU_GPU TRUE)
109-
set(LIBOMPTARGET_DEP_AMDGPU_ARCH "${arch_string}")
107+
set(LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST "${amdgpu_arch_list}")
110108
endif()
111109
endif()
112110

openmp/libomptarget/test/lit.cfg

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,16 @@ def add_libraries(source):
189189

190190
def get_arch_from_target(libomptarget_target):
191191
if libomptarget_target.startswith('amdgcn'):
192-
aomp_gpu = os.environ.get("AOMP_GPU")
193-
if not aomp_gpu:
194-
print("WARNING: AOMP_GPU not set, defaulting to gfx90a")
195-
return 'gfx90a'
196-
return aomp_gpu
192+
device = os.environ.get("ROCR_VISIBLE_DEVICES")
193+
if not device:
194+
device = 0
195+
else:
196+
device = int(device.split(",")[0])
197+
amd_gpu_list = config.amdgpu_test_arch.split(";")
198+
if len(amd_gpu_list) - 1 < device:
199+
print("ERROR: Device selected via ROCR_VISIBLE_DEVICES exceeds number of available AMD devices")
200+
os._exit(1)
201+
return amd_gpu_list[device]
197202
if libomptarget_target.startswith('x86_64'):
198203
return 'x86-64'
199204
return 'native'
@@ -323,10 +328,9 @@ for libomptarget_target in config.libomptarget_all_targets:
323328
get_arch_from_target(libomptarget_target)))
324329
config.substitutions.append(("%clangxxx-force-usm-" + libomptarget_target, \
325330
"%clangxx %openmp_flags -fopenmp-force-usm %cuda_flags %flags %flags_clang -fopenmp-targets=" +\
326-
remove_suffix_if_present(libomptarget_target)))
327-
config.substitutions.append(("%clangxxx-force-usm-" + libomptarget_target, \
328-
"%clangxx %openmp_flags -fopenmp-force-usm %cuda_flags %flags %flags_clang -fopenmp-targets=" +\
329-
remove_suffix_if_present(libomptarget_target)))
331+
remove_suffix_if_present(libomptarget_target) + " -Xopenmp-target=" +\
332+
remove_suffix_if_present(libomptarget_target) + " -march=" +\
333+
get_arch_from_target(libomptarget_target)))
330334
config.substitutions.append(("%clang-" + libomptarget_target, \
331335
"%clang %openmp_flags %cuda_flags %flags %flags_clang -fopenmp-targets=" +\
332336
remove_suffix_if_present(libomptarget_target) + " -Xopenmp-target=" +\

0 commit comments

Comments
 (0)