shibatch / sleef

SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT
https://sleef.org
Boost Software License 1.0
646 stars 131 forks source link

Building sleef quad inline for CUDA problem #559

Open mrjbom opened 3 months ago

mrjbom commented 3 months ago

I need to use the quadruple-precision floating point number in CUDA. The Quad-precision math library reference for CUDA shows that I should use _sleefquadinline_cuda.h and the type Sleef_quadx1_.

I have: Sleef 3.6.1 from GitHub Visual Studio 2022 CUDA 12.5 Toolkit

I downloaded Sleef-3.6.1 from github. I started the CMake GUI, clicked Configure and then set the following options: SLEEF_ENABLE_CUDA=true SLEEF_ENFORCE_CUDA=true SLEEF_BUILD_QUAD=true SLEEF_BUILD_INLINE_HEADERS=true I clicked Configure again, then Generate and Open Project, built the x64 Release several times so that all the files would be builded at all (some files are not built the first time). I tried using a file search to find the file sleefquadinline_cuda.h, but I didn't find it anywhere. What am I doing wrong?

joanaxcruz commented 3 months ago

Hi, will look into this today!

mrjbom commented 3 months ago

@joanaxcruz, Thanks, I'll be waiting

blapie commented 2 months ago

Hi! We realise the documentation to get started with CUDA is very minimalistic/inexistent. Will make sure this is improved before closing this issue. In the meantime could you please provide a log for your configure and build steps? We are a bit limited when it comes to reproducing issues on Windows, but I had a go on Linux/Ubuntu and it seems to be working correctly there with something like

#!/bin/bash

COMMON_CMAKE_CFLAGS="-DSLEEF_SHOW_CONFIG=ON \
  -DSLEEF_BUILD_INLINE_HEADERS=ON \
  -DSLEEF_BUILD_DFT=OFF \
  -DSLEEF_BUILD_QUAD=ON \
  -DSLEEF_BUILD_SCALAR_LIB=OFF \
  -DSLEEF_BUILD_TESTS=OFF \
  -DSLEEF_ENABLE_CUDA=ON \
  -DSLEEF_ENFORCE_CUDA=ON \
  -DCMAKE_VERBOSE_MAKEFILE=ON"

rm -rf build-cuda
cmake -S . -B build-cuda -GNinja ${COMMON_CMAKE_CFLAGS}
cmake --build build-cuda -j --clean-first

My log starts with something like this where you see that CMAKE_CUDA_COMPILER is detected and set, thus enabling the CUDA code and header to be emitted by SLEEF.

-- The C compiler identification is GNU 12.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/arm/gcc-12.3.0_Ubuntu-22.04/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CUDA compiler identification is NVIDIA 12.5.82
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda-12.5/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
...

Then, the inline headers are available in build-cuda/include/

mrjbom commented 2 months ago

@blapie Hi. I did the same as you and tried to build the library in Ubuntu and I succeeded. But I still couldn't compile the test code because sleefquadinline_cuda.h uses the undeclared type vdouble_cuda_sleefq and so on. The compiler says: error: identifier "vdouble_cuda_sleefq" is undefined

As for Windows: CMake finds the CUDA compiler but does not set the CMAKE_CUDA_COMPILER variable.

The CUDA compiler identification is NVIDIA 12.5.40
Detecting CUDA compiler ABI info
Detecting CUDA compiler ABI info - done
Check for working CUDA compiler: D:/ProgrammingLibs/CUDA/v12.5/bin/nvcc.exe - skipped
Detecting CUDA compile features
Detecting CUDA compile features - done

FAILED CUDA COMPILER Some CUDA variables are set, but CMAKE_CUDA_COMPILER is not. This problem does not occur in Ubuntu.