diff --git a/.github/workflows/CMakeBuildUbuntu.yml b/.github/workflows/CMakeBuildUbuntu.yml new file mode 100644 index 0000000..f7ba2a3 --- /dev/null +++ b/.github/workflows/CMakeBuildUbuntu.yml @@ -0,0 +1,71 @@ +name: Building For Ubuntu 🐧 + +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + BUILD_TYPE: Release + packageName: hipims-cuda-amd64.deb + +jobs: + BuildForUbuntu: + name: 🐧 Build for Ubuntu + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: ♻️ Get Nvdia Driver Cache + uses: Jimver/cuda-toolkit@v0.2.18 + id: cuda-toolkit + with: + method: network + sub-packages: '["nvcc"]' + + - name: 🏗️ Configure CMake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: 🛠️ Build + run: | + cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 + + - name: 🗄️ Set up Debian Package + run: | + mkdir -p debian/usr/local/bin + cp release/bin/* debian/usr/local/bin/ + + - name: 🔨 Build Debian Package + run: | + dpkg-deb --build debian ${{env.packageName}} + + - name: ⬆️ Upload deb package + uses: actions/upload-artifact@v4 + with: + name: debArtifact + path: "${{github.workspace}}/${{env.packageName}}" + + ReleaseArtifact: + name: 🚀 Release Project + runs-on: ubuntu-latest + needs: BuildForUbuntu + steps: + - name: ⬇️ Download deb + uses: actions/download-artifact@v4 + with: + name: debArtifact + + - name: 📦 Add binaries to Release Tag + uses: softprops/action-gh-release@v2 + with: + tag_name: Continuous + files: | + ${{env.packageName}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/CMakeBuildWindows.yml b/.github/workflows/CMakeBuildWindows.yml new file mode 100644 index 0000000..7899a9a --- /dev/null +++ b/.github/workflows/CMakeBuildWindows.yml @@ -0,0 +1,109 @@ +name: Building For Windows 🪟 + +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + BUILD_TYPE: Release + +jobs: + BuildForWindows: + name: 🪟 Build for Windows + runs-on: windows-latest + env: + CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.6" + CUDA_PATH_BIN: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.6\\bin" + CUDA_PATH_V12_6: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.6" + CUDA_PATH_VX_Y: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.6" + + NVIDA_DRIVER_URL: "https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda_12.6.2_560.94_windows.exe" + NVIDA_DRIVER_FILE_NAME: "cuda_12.6.2_560.94_windows.exe" + NVIDA_INSTALL_ARGS: "-s nvcc_12.6 visual_studio_integration_12.6 cudart_12.6" + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: ♻️ Get Nvdia Driver Cache + id: cache-nvdia + uses: actions/cache@v4 + with: + path: nvidia_toolkit_cache + key: nvidia-toolkit-${{ env.NVIDA_DRIVER_FILE_NAME }} + + - name: ⬇️ Download Nvidia Driver + if: steps.cache-nvdia.outputs.cache-hit != 'true' + run: Invoke-WebRequest -Uri $env:NVIDA_DRIVER_URL -OutFile $env:NVIDA_DRIVER_FILE_NAME + + - name: ⚙️ Install Nvidia Driver + if: steps.cache-nvdia.outputs.cache-hit != 'true' + run: | + Start-Process -FilePath $env:NVIDA_DRIVER_FILE_NAME -ArgumentList $env:NVIDA_INSTALL_ARGS -Wait -NoNewWindow + + - name: 🗄️Setup for Cache Nvidia Driver + if: steps.cache-nvdia.outputs.cache-hit != 'true' + run: | + mkdir -p "nvidia_toolkit_cache" + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\" "nvidia_toolkit_cache\" /s /e /y + + - name: 💾 Cache Nvidia Driver + id: cache-primes-save + if: steps.cache-nvdia.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: nvidia_toolkit_cache + key: nvidia-toolkit-${{ env.NVIDA_DRIVER_FILE_NAME }} + + - name: 🔄 Restore NVIDIA Toolkit from cache + if: steps.cache-nvdia.outputs.cache-hit == 'true' + run: | + xcopy "nvidia_toolkit_cache\" "C:\Program Files\NVIDIA GPU Computing Toolkit\" /s /e /y + xcopy "nvidia_toolkit_cache\CUDA\v12.6\extras\visual_studio_integration\MSBuildExtensions\" "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\BuildCustomizations\" /s /e /y + + - shell: bash + name: 🛠️ Add Nvidia to path + run: | + echo "CUDA_PATH=$CUDA_PATH" >> $GITHUB_ENV + echo "CUDA_PATH_V12_6=$CUDA_PATH_V12_6" >> $GITHUB_ENV + echo "CUDA_PATH_VX_Y=$CUDA_PATH_VX_Y" >> $GITHUB_ENV + echo "$CUDA_PATH_BIN" >> $GITHUB_PATH + + - name: 🏗️ Configure CMake + run: | + cmake -B ${{github.workspace}}\build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: 🛠️ Build + run: cmake --build ${{github.workspace}}\build --config ${{env.BUILD_TYPE}} -j 4 + + - name: ⬆️ Upload Exe File + uses: actions/upload-artifact@v4 + with: + name: binariesArtifact + path: "${{github.workspace}}\\release\\bin\\Release" + + ReleaseArtifact: + name: 🚀 Release Project + runs-on: ubuntu-latest + needs: BuildForWindows + steps: + - name: ⬇️ Download exe + uses: actions/download-artifact@v4 + with: + name: binariesArtifact + + - name: 📦 Add binaries to Release Tag + uses: softprops/action-gh-release@v2 + with: + tag_name: Continuous + files: | + hipims-flood.exe + hipims-flood-mgpus.exe + hipims-landslide.exe + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/actionCacheClear.yml b/.github/workflows/actionCacheClear.yml new file mode 100644 index 0000000..12b2d57 --- /dev/null +++ b/.github/workflows/actionCacheClear.yml @@ -0,0 +1,30 @@ +name: Clear cache + +on: + workflow_dispatch: + +permissions: + actions: write + +jobs: + clear-cache: + runs-on: ubuntu-latest + steps: + - name: Clear cache + uses: actions/github-script@v6 + with: + script: | + console.log("About to clear") + const caches = await github.rest.actions.getActionsCacheList({ + owner: context.repo.owner, + repo: context.repo.repo, + }) + for (const cache of caches.data.actions_caches) { + console.log(cache) + github.rest.actions.deleteActionsCacheById({ + owner: context.repo.owner, + repo: context.repo.repo, + cache_id: cache.id, + }) + } + console.log("Clear completed") \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bfb1e64 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/build/ +/release/ +/debian/usr/ +*.deb \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index fd3ba79..d030b22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,24 @@ -cmake_minimum_required(VERSION 2.6) -#project name -project(HiPIMs) +cmake_minimum_required(VERSION 3.10) -find_package(CUDA) +project(HiPIMs LANGUAGES CXX CUDA) +set(CMAKE_CUDA_STANDARD 14) +set(CMAKE_CUDA_STANDARD_REQUIRED ON) +set(CMAKE_CUDA_ARCHITECTURES 80) +set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda") +set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +# Enable debug symbols across all platforms IF(WIN32) set(PLATFORM_CXX_FLAGS /Zi) - set(CUDA_SEPARABLE_COMPILATION ON) - set(CUDA_NVCC_FLAGS -arch=sm_35;--expt-extended-lambda) ENDIF(WIN32) IF(UNIX) set(PLATFORM_CXX_FLAGS "-pthread -std=c++11 -O3") - #set(CUDA_SEPARABLE_COMPILATION ON) - set(CUDA_NVCC_FLAGS -arch=sm_35;--expt-extended-lambda) ENDIF(UNIX) list(APPEND CMAKE_CXX_FLAGS ${PLATFORM_CXX_FLAGS}) @@ -21,7 +26,6 @@ list(APPEND CMAKE_CXX_FLAGS ${PLATFORM_CXX_FLAGS}) message("CXX Flags: " ${CMAKE_CXX_FLAGS}) message("NVCC Flags: " ${CUDA_NVCC_FLAGS}) - add_subdirectory(lib) add_subdirectory(apps/cudaFloodSolver) add_subdirectory(apps/cudaMultiGPUsFloodSolver) diff --git a/apps/cudaFloodSolver/CMakeLists.txt b/apps/cudaFloodSolver/CMakeLists.txt index d455884..db3869b 100644 --- a/apps/cudaFloodSolver/CMakeLists.txt +++ b/apps/cudaFloodSolver/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.10) set(EXE hipims-flood) set(SRCS cuda_flood_solver.cu) @@ -17,7 +17,7 @@ list(REMOVE_DUPLICATES GC_INCLUDE_DIRS) include_directories(${GC_INCLUDE_DIRS}) -cuda_add_executable(${EXE} ${SRCS}) +add_executable(${EXE} ${SRCS}) add_dependencies(${EXE} lib cuda_lib) #set (CUDA_NVCC_FLAGS "-arch=sm_20") diff --git a/apps/cudaIntegratedShallowFlowSolver/CMakeLists.txt b/apps/cudaIntegratedShallowFlowSolver/CMakeLists.txt index b014d8f..8030db3 100755 --- a/apps/cudaIntegratedShallowFlowSolver/CMakeLists.txt +++ b/apps/cudaIntegratedShallowFlowSolver/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.10) set(EXE hipims-landslide) set(SRCS cuda_integrated_shallow_flow_solver.cu) @@ -17,7 +17,7 @@ list(REMOVE_DUPLICATES GC_INCLUDE_DIRS) include_directories(${GC_INCLUDE_DIRS}) -cuda_add_executable(${EXE} ${SRCS}) +add_executable(${EXE} ${SRCS}) add_dependencies(${EXE} lib cuda_lib) #set (CUDA_NVCC_FLAGS "-arch=sm_20") diff --git a/apps/cudaMultiGPUsFloodSolver/CMakeLists.txt b/apps/cudaMultiGPUsFloodSolver/CMakeLists.txt index ed901b1..0c3e52d 100644 --- a/apps/cudaMultiGPUsFloodSolver/CMakeLists.txt +++ b/apps/cudaMultiGPUsFloodSolver/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.10) set(EXE hipims-flood-mgpus) set(SRCS cuda_mgpus_flood_solver.cu) @@ -17,7 +17,7 @@ list(REMOVE_DUPLICATES GC_INCLUDE_DIRS) include_directories(${GC_INCLUDE_DIRS}) -cuda_add_executable(${EXE} ${SRCS}) +add_executable(${EXE} ${SRCS}) add_dependencies(${EXE} lib cuda_lib) #set (CUDA_NVCC_FLAGS "-arch=sm_20") diff --git a/debian/DEBIAN/control b/debian/DEBIAN/control new file mode 100644 index 0000000..69b42aa --- /dev/null +++ b/debian/DEBIAN/control @@ -0,0 +1,16 @@ +Package: hipims-cuda +Version: 1.0 +Section: utils +Priority: optional +Architecture: amd64 +Depends: libc6 (>= 2.30) +Maintainer: HIPIMS +Description: HiPIMS is a high-performance GPU-based flood simulation system. + HiPIMS standards for High-Performance Integrated hydrodynamic Modelling System. + It uses state-of-art numerical schemes (Godunov-type finite volume) to solve the + 2D shallow water equations for flood simulations. To support high-resolution flood + simulations, HiPIMS is implemented on multiple GPUs (Graphics Processing Units) + using CUDA/C++ languages to achieve high-performance computing. Since HiPIMS has + a modular and flexible structure, it has great potential to be further developed + for other applications in hydrological science as long as the problem can be solved + on a uniform rectangular grid. diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 451f63b..3e6eb3e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.10) # nvcc flags @@ -28,6 +28,6 @@ else() include_directories(${GC_INCLUDE_DIRS}) add_library(lib STATIC ${gc_srcs}) #cuda_add_library(cuda_lib STATIC ${gc_cuda_srcs}) -cuda_add_library(cuda_lib STATIC ${gc_cuda_srcs}) +add_library(cuda_lib STATIC ${gc_cuda_srcs}) endif()