Skip to content

Commit

Permalink
fix CUDA in windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ichinii committed Jul 31, 2024
1 parent 9f40088 commit c3e3ce6
Show file tree
Hide file tree
Showing 17 changed files with 190 additions and 104 deletions.
23 changes: 7 additions & 16 deletions .github/workflows/releaseDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,16 @@ jobs:
echo "${{github.workspace}}/boost" >> $GITHUB_PATH
echo "${{github.workspace}}/boost/boost" >> $GITHUB_PATH
- name: Install Cuda (Windows)
if: matrix.os == 'windows-latest'
uses: Jimver/[email protected]
id: cuda-toolkit-windows
with:
cuda: '12.3.2'

- name: Add Cuda to PATH (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "Installed cuda version is: ${{steps.cuda-toolkit-windows.outputs.cuda}}"
echo "Cuda install location: ${{steps.cuda-toolkit-windows.outputs.CUDA_PATH}}"
echo "${{steps.cuda-toolkit-windows.outputs.CUDA_PATH}}" >> $GITHUB_PATH
echo "${{steps.cuda-toolkit-windows.outputs.CUDA_PATH}}/bin" >> $GITHUB_PATH
echo "nvcc -V"
- name: Setup CUDA Toolkit
id: cuda-toolkit
shell: pwsh
run: .\Scripts\setup-cuda.ps1
env:
INPUT_CUDA_VERSION: 12.5.1

- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DRAYX_REQUIRES_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR="${{steps.cuda-toolkit-windows.outputs.CUDA_PATH}}"
run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DRAYX_REQUIRES_CUDA=ON

- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testUbuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
cuda: '12.3.2'

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRAYX_REQUIRES_CUDA=ON
run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRAYX_REQUIRES_CUDA=ON -DCMAKE_CXX_COMPILER=/usr/bin/cuda-g++

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
Expand Down
52 changes: 22 additions & 30 deletions .github/workflows/testWindows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ jobs:
git submodule sync
git submodule update --init --recursive
- name: Prepare Vulkan SDK
uses: humbletim/[email protected]
with:
vulkan-query-version: 1.3.275.0
vulkan-components: Vulkan-Headers, Vulkan-Loader, SPIRV-Cross, SPIRV-Tools, Glslang
vulkan-use-cache: true

- name: Download glslangValidator
run: curl -L -o glslang.zip https://github.com/KhronosGroup/glslang/releases/download/main-tot/glslang-master-windows-Release.zip

- name: Extract glslangValidator
shell: powershell
run: Expand-Archive -Path glslang.zip -DestinationPath ${{github.workspace}}/glslang

- name: Add glslangValidator to PATH
run: echo "${{github.workspace}}/glslang/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# - name: Prepare Vulkan SDK
# uses: humbletim/[email protected]
# with:
# vulkan-query-version: 1.3.275.0
# vulkan-components: Vulkan-Headers, Vulkan-Loader, SPIRV-Cross, SPIRV-Tools, Glslang
# vulkan-use-cache: true
#
# - name: Download glslangValidator
# run: curl -L -o glslang.zip https://github.com/KhronosGroup/glslang/releases/download/main-tot/glslang-master-windows-Release.zip
#
# - name: Extract glslangValidator
# shell: powershell
# run: Expand-Archive -Path glslang.zip -DestinationPath ${{github.workspace}}/glslang
#
# - name: Add glslangValidator to PATH
# run: echo "${{github.workspace}}/glslang/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Install boost
uses: MarkusJx/[email protected]
Expand All @@ -48,23 +48,15 @@ jobs:
echo "${{github.workspace}}/boost" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "${{github.workspace}}/boost/boost" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Cuda
uses: Jimver/[email protected]
- name: Setup CUDA Toolkit
id: cuda-toolkit
with:
cuda: '12.3.2'

- name: Add Cuda to PATH
run: |
echo "Installed cuda version is: ${{steps.cuda-toolkit.outputs.cuda}}"
echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
echo "nvcc -V"
nvcc -V
echo "${{steps.cuda-toolkit.outputs.CUDA_PATH}}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "${{steps.cuda-toolkit.outputs.CUDA_PATH}}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
run: .\Scripts\setup-cuda.ps1
env:
INPUT_CUDA_VERSION: 12.5.1

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRAYX_REQUIRES_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR="${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DRAYX_REQUIRES_CUDA=ON

- name: Build
run: |
Expand Down
20 changes: 14 additions & 6 deletions Intern/rayx-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ endif()
if(MSVC)
message(STATUS "MSVC")

set(MSVC_CXX_FLAGS /W3 /wd4251 /wd4267)
set(MSVC_CXX_FLAGS /W3) # enable warning level 3
list(APPEND MSVC_CXX_FLAGS /wd4251) # disable warnings related to missing DLL export annotation on members of exported classes
list(APPEND MSVC_CXX_FLAGS /wd4267) # disable warnings related to narrowing conversion
if(WERROR STREQUAL "YES")
list(APPEND MSVC_CXX_FLAGS /WX)
list(APPEND MSVC_CXX_FLAGS /WX) # handle warnings as errors
message(STATUS "Werror mode")
endif()
prepend_xcompiler(MSVC_CXX_FLAGS MSVC_CUDA_FLAGS)
list(APPEND MSVC_CUDA_FLAGS --diag-suppress 1394) # disable warnings related to missing DLL export annotation on members of exported classes

target_compile_options(${PROJECT_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${MSVC_CXX_FLAGS}>)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:${MSVC_CUDA_FLAGS}>)
Expand Down Expand Up @@ -143,11 +146,16 @@ target_compile_definitions(${PROJECT_NAME}
$<$<CONFIG:RelWithDebInfo>:RAYX_DEBUG_MODE>
)

# Only build gpu tracer when CUDA is enabled
if(alpaka_ACC_GPU_CUDA_ENABLE)
target_compile_definitions(${PROJECT_NAME} PUBLIC RAYX_CUDA_ENABLED)
# Inform about the cuda and hip config of alpaka
if(alpaka_ACC_GPU_CUDA_ENABLE OR alpaka_ACC_GPU_HIP_ENABLE)
if(alpaka_ACC_GPU_CUDA_ENABLE)
target_compile_definitions(${PROJECT_NAME} PUBLIC RAYX_CUDA_ENABLED)
endif()
if(alpaka_ACC_GPU_HIP_ENABLE)
target_compile_definitions(${PROJECT_NAME} PUBLIC RAYX_HIP_ENABLED)
endif()
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC NO_GPU_TRACER)
target_compile_definitions(${PROJECT_NAME} PUBLIC RAYX_NO_GPU_TRACER)
endif()

# -----------------
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Beamline/LightSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "Data/xml.h"
#include "EnergyDistribution.h"
#include "Shader/Ray.h"
#include "Shader/Strings.h"
#include "Data/Strings.h"

namespace RAYX {
enum class SpreadType { HardEdge, SoftEdge, SeparateEnergies }; // default WhiteBand
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Data/Importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "DesignElement/DesignElement.h"
#include "DesignElementWriter.h"
#include "DesignSourceWriter.h"
#include "Shader/Strings.h"
#include "Strings.h"

using RAYX::ElementType;

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Data/xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "Beamline/LightSource.h"
#include "Debug/Debug.h"
#include "Shader/Constants.h"
#include "Shader/Strings.h"
#include "Strings.h"
#include "angle.h"

namespace RAYX::xml {
Expand Down
54 changes: 27 additions & 27 deletions Intern/rayx-core/src/Shader/Complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Common.h"

#if defined(RAYX_CUDA_ENABLED)
#include <thrust/complex.h>
#include <cuda/std/complex>
#else
#include <complex>
#endif
Expand All @@ -13,7 +13,7 @@ namespace RAYX {
namespace complex {
template <typename T>
#if defined(RAYX_CUDA_ENABLED)
using tcomplex = thrust::complex<T>;
using tcomplex = cuda::std::complex<T>;
#else
using tcomplex = std::complex<T>;
#endif
Expand All @@ -27,31 +27,31 @@ using cmat3 = glm::tmat3x3<complex::Complex>;

namespace complex {
#if defined(RAYX_CUDA_ENABLED)
using thrust::abs;
using thrust::arg;
using thrust::conj;
using thrust::exp;
using thrust::log;
using thrust::log10;
using thrust::norm;
using thrust::polar;
using thrust::pow;
using thrust::proj;
using thrust::sqrt;

using thrust::acos;
using thrust::asin;
using thrust::atan;
using thrust::cos;
using thrust::sin;
using thrust::tan;

using thrust::acosh;
using thrust::asinh;
using thrust::atanh;
using thrust::cosh;
using thrust::sinh;
using thrust::tanh;
using cuda::std::abs;
using cuda::std::arg;
using cuda::std::conj;
using cuda::std::exp;
using cuda::std::log;
using cuda::std::log10;
using cuda::std::norm;
using cuda::std::polar;
using cuda::std::pow;
using cuda::std::proj;
using cuda::std::sqrt;

using cuda::std::acos;
using cuda::std::asin;
using cuda::std::atan;
using cuda::std::cos;
using cuda::std::sin;
using cuda::std::tan;

using cuda::std::acosh;
using cuda::std::asinh;
using cuda::std::atanh;
using cuda::std::cosh;
using cuda::std::sinh;
using cuda::std::tanh;
#else
using std::abs;
using std::arg;
Expand Down
1 change: 0 additions & 1 deletion Intern/rayx-core/src/Shader/Throw.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// throws an error, and termiantes the program
// TODO(Sven): rethink error handling. just instantly terminate with RAYX_ERR or use recordFinalEvent?
// #define _throw(string) recordFinalEvent(_ray, ETYPE_FATAL_ERROR)
#include "Debug/Debug.h"
// #define _throw(string) RAYX_ERR << string
#define _throw(string) assert(false)
// #endif
12 changes: 6 additions & 6 deletions Intern/rayx-core/src/Tracer/DeviceConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ DeviceType platformToDeviceType<alpaka::PlatformCpu>() {
return DeviceType::Cpu;
}

#if defined(RAYX_CUDA)
#if defined(RAYX_CUDA_ENABLED)
template <>
DeviceType platformToDeviceType<alpaka::PlatformCudaRt>() {
return DeviceType::GpuCuda;
}
#endif

#if defined(RAYX_HIP)
#if defined(RAYX_HIP_ENABLED)
template <>
DeviceType platformToDeviceType<alpaka::PlatformHipRt>() {
return DeviceType::GpuHip;
Expand All @@ -49,14 +49,14 @@ struct AccForPlatform<alpaka::PlatformCpu, Dim, Idx> {
using type = RAYX::DefaultCpuAcc<Dim, Idx>;
};

#if defined(RAYX_CUDA)
#if defined(RAYX_CUDA_ENABLED)
template <typename Dim, typename Idx>
struct AccForPlatform<alpaka::PlatformCudaRt, Dim, Idx> {
using type = alpaka::AccGpuCudaRt<Dim, Idx>;
};
#endif

#if defined(RAYX_HIP)
#if defined(RAYX_HIP_ENABLED)
template <typename Dim, typename Idx>
struct AccForPlatform<alpaka::PlatformHipRt, Dim, Idx> {
using type = alpaka::AccGpuHipRt<Dim, Idx>;
Expand Down Expand Up @@ -104,11 +104,11 @@ std::vector<Device> getAvailableDevices(DeviceType deviceType = DeviceType::All)

if (deviceType & DeviceType::Cpu) append(alpaka::PlatformCpu());

#if defined(RAYX_CUDA)
#if defined(RAYX_CUDA_ENABLED)
if (deviceType & DeviceType::GpuCuda) append(alpaka::PlatformCudaRt());
#endif

#if defined(RAYX_HIP)
#if defined(RAYX_HIP_ENABLED)
if (deviceType & DeviceType::GpuHip) append(alpaka::PlatformHipRt());
#endif

Expand Down
12 changes: 2 additions & 10 deletions Intern/rayx-core/src/Tracer/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@ namespace RAYX {
// declare invalid Acc
struct AccNull {};

#if defined(ALPAKA_ACC_GPU_CUDA_ENABLED)
#define RAYX_CUDA
#endif

#if defined(ALPAKA_ACC_GPU_HIP_ENABLED)
#define RAYX_HIP
#endif

template <typename Dim, typename Idx>
#if defined(RAYX_CUDA)
#if defined(RAYX_CUDA_ENABLED)
using GpuAccCuda = alpaka::AccGpuCudaRt<Dim, Idx>;
#else
using GpuAccCuda = AccNull;
#endif

template <typename Dim, typename Idx>
#if defined(RAYX_HIP)
#if defined(RAYX_HIP_ENABLED)
using GpuAccHip = alpaka::AccGpuHipRt<Dim, Idx>;
#else
using GpuAccHip = AccNull;
Expand Down
4 changes: 2 additions & 2 deletions Intern/rayx-core/src/Tracer/Tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ inline std::shared_ptr<RAYX::DeviceTracer> createDeviceTracer(DeviceType deviceT

switch (deviceType) {
case DeviceType::GpuCuda:
#if defined(RAYX_CUDA)
#if defined(RAYX_CUDA_ENABLED)
using GpuAccCuda = RAYX::GpuAccCuda<Dim, Idx>;
return std::make_shared<RAYX::SimpleTracer<GpuAccCuda>>(deviceIndex);
#else
RAYX_ERR << "Failed to create Tracer with Cuda device. Cuda was disabled during build.";
return nullptr;
#endif
case DeviceType::GpuHip:
#if defined(RAYX_HIP)
#if defined(RAYX_HIP_ENABLED)
using GpuAccHip = RAYX::GpuAccHip<Dim, Idx>;
return std::make_shared<RAYX::SimpleTracer<GpuAccHip>>(deviceIndex);
#else
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-ui/src/UserInterface/BeamlineDesignHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "Beamline/StringConversion.h"
#include "Debug/Instrumentor.h"
#include "Shader/Strings.cpp"
#include "Data/Strings.cpp"

void BeamlineDesignHandler::showBeamlineDesignWindow(UIBeamlineInfo& uiBeamlineInfo) {
// RAYX_PROFILE_FUNCTION_STDOUT();
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-ui/src/UserInterface/BeamlineOutliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <fstream>

#include "Shader/Strings.h"
#include "Data/Strings.h"

BeamlineOutliner::BeamlineOutliner(/* args */) {}

Expand Down
Loading

0 comments on commit c3e3ce6

Please sign in to comment.