GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
224 stars 105 forks source link

Compile failure with conda compiler on macos #1217

Closed jmeyers314 closed 1 year ago

jmeyers314 commented 1 year ago

Trying to compile the main branch using the conda compiler that comes with the Rubin Science Pipelines on MacOS 12.6.3. The compiler is identified with Yay! This version of clang supports GPU! (which seems wrong as macs don't really support nvptx nowadays, but maybe it's capable of cross-compiling?). When checking for cpp11 a bit later in setup.py though, it errors out with:

Trying compile command:
x86_64-apple-darwin13.4.0-clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/josh/src/lsst/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-5.1.0/include -fPIC -O2 -isystem /Users/josh/src/lsst/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-5.1.0/include -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/josh/src/lsst/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-5.1.0/include -D_FORTIFY_SOURCE=2 -isystem /Users/josh/src/lsst/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-5.1.0/include -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 -c /Users/josh/src/GalSim/tmp/tmpmofvgpp3.cpp -o /Users/josh/src/GalSim/tmp/tmpy5z_ilkd.o
Output was:
    clang-14: error: cannot find libdevice for sm_35; provide path to different CUDA installation via '--cuda-path', or pass '-nocudalib' to build without linking with libdevice

The compiler x86_64-apple-darwin13.4.0-clang with flags -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 did not successfully compile C++11 code
error: Compiler is not C++-11 compatible

So looks like a GPU problem. Is there a way to force no-gpu with an env variable or something?

jmeyers314 commented 1 year ago

If I comment out this bit: https://github.com/GalSim-developers/GalSim/blob/main/setup.py#L151-L154. Then I'm back in business.

rmjarvis commented 1 year ago

@jamesp-epcc

Looks like we need a different way to identify a GPU-compatible compiler, which doesn't falsely trigger on the Apple clang variant.

jamesp-epcc commented 1 year ago

OK, it looks as if it's not safe to assume that a compiler that reports nvptx support can actually perform a successful GPU build. Maybe Apple supplies their core compiler with nvptx enabled but it requires other software to function properly. I'll replace this with a check that actually builds a small GPU program and ensures there are no errors.

jamesp-epcc commented 1 year ago

@jmeyers314 would you be able to check if this version of setup.py fixes the problem for you? https://raw.githubusercontent.com/jamesp-epcc/GalSim/gpu_compiler_detection/setup.py

It works for me on Perlmutter but I don't have a Mac OS machine to hand for testing.

jmeyers314 commented 1 year ago

Yep. That looks like it works.