Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building GPU-enabled GalSim using NVIDIA compiler #1230

Merged
merged 4 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions include/galsim/Std.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ class Debugger // Use a Singleton model so it can be included multiple times.
#define verbose_level Debugger::instance().get_level()
#define xassert(x) assert(x)
#else
#define dbg if(false) (std::cerr)
#define xdbg if(false) (std::cerr)
#define xxdbg if(false) (std::cerr)
extern std::ostream* dbgout;
#define dbg if(false) (*dbgout)
#define xdbg if(false) (*dbgout)
#define xxdbg if(false) (*dbgout)
#define set_dbgout(dbgout)
#define set_verbose(level)
#define xassert(x)
Expand Down
17 changes: 15 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def all_files_from(dir, ext=''):

copt = {
'gcc' : ['-O2','-std=c++11','-fvisibility=hidden','-fopenmp'],
'gcc w/ GPU' : ['-O2','-std=c++11','-fvisibility=hidden','-fopenmp','-foffload=nvptx-none'],
'gcc w/ GPU' : ['-O2','-std=c++11','-fvisibility=hidden','-fopenmp','-foffload=nvptx-none','-DGALSIM_USE_GPU'],
'icc' : ['-O2','-vec-report0','-std=c++11','-openmp'],
'clang' : ['-O2','-std=c++11',
'-Wno-shorten-64-to-32','-fvisibility=hidden','-stdlib=libc++'],
Expand All @@ -85,18 +85,20 @@ def all_files_from(dir, ext=''):
'clang w/ GPU' : ['-O2','-msse2','-std=c++11','-fopenmp','-fopenmp-targets=nvptx64-nvidia-cuda',
'-Wno-openmp-mapping','-Wno-unknown-cuda-version',
'-Wno-shorten-64-to-32','-fvisibility=hidden', '-DGALSIM_USE_GPU'],
'nvc++' : ['-O2','-std=c++11','-mp=gpu','-DGALSIM_USE_GPU'],
'unknown' : [],
}
lopt = {
'gcc' : ['-fopenmp'],
'gcc w/ GPU' : ['-fopenmp','-foffload=nvptx-none'],
'gcc w/ GPU' : ['-fopenmp','-foffload=nvptx-none', '-foffload=-lm'],
'icc' : ['-openmp'],
'clang' : ['-stdlib=libc++'],
'clang w/ OpenMP' : ['-stdlib=libc++','-fopenmp'],
'clang w/ Intel OpenMP' : ['-stdlib=libc++','-liomp5'],
'clang w/ manual OpenMP' : ['-stdlib=libc++','-lomp'],
'clang w/ GPU' : ['-fopenmp','-fopenmp-targets=nvptx64-nvidia-cuda',
'-Wno-openmp-mapping','-Wno-unknown-cuda-version'],
'nvc++' : ['-mp=gpu'],
'unknown' : [],
}

Expand Down Expand Up @@ -143,6 +145,9 @@ def get_compiler_type(compiler, check_unknown=True, output=False):
line = lines[0].decode(encoding='UTF-8')
if line.startswith('Configured'):
line = lines[1].decode(encoding='UTF-8')
# nvc++ version info starts with a blank line
if line.strip() == "":
line = lines[1].decode(encoding='UTF-8')

if 'clang' in line:
# clang 3.7 is the first with openmp support. But Apple lies about the version
Expand Down Expand Up @@ -180,6 +185,8 @@ def get_compiler_type(compiler, check_unknown=True, output=False):
print("Yay! This version of gcc supports GPU!")
return 'gcc w/ GPU'
return 'gcc'
elif 'nvc++' in line or 'nvcc' in line or 'NVIDIA' in line:
return 'nvc++'
elif 'clang' in cc:
return 'clang'
elif 'gcc' in cc or 'g++' in cc:
Expand Down Expand Up @@ -762,6 +769,12 @@ def fix_compiler(compiler, njobs):
except (AttributeError, ValueError):
pass

# nvc++ doesn't support -Wno-unused-result
try:
compiler.compiler_so.remove("-Wno-unused-result")
except (AttributeError, ValueError):
pass

# Figure out what compiler it will use
comp_type = get_compiler_type(compiler, output=True)
cc = compiler.compiler_so[0]
Expand Down
Loading