diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44c4a94..01fae70 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,18 +23,9 @@ jobs: strategy: fail-fast: false matrix: - cxx: [17, 20] - build_type: ["RelWithDebInfo"] - compiler: - [ - "g++-11", - "g++-10", - "clang++-11", - "clang++-12", - "clang++-13", - "clang++-14" - ] - name: "Ubuntu 22.04 (${{ matrix.compiler }}, C++${{ matrix.cxx }}, ${{matrix.build_type}})" + cxx: [20] + build_type: ["Release", "Debug"] + name: "Ubuntu 22.04 (C++${{ matrix.cxx }}, ${{matrix.build_type}})" runs-on: ubuntu-22.04 outputs: id: "${{ matrix.compiler }} (C++${{ matrix.cxx }}, ${{ matrix.build_type }})" @@ -43,71 +34,21 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: "ccache-ubuntu2204_no_cuda-${{ matrix.compiler }}-${{ matrix.cxx }}-${{ matrix.build_type }}" + key: "ccache-ubuntu2204_no_cuda-${{ matrix.cxx }}-${{ matrix.build_type }}" max-size: 256M - name: "update APT database" run: sudo apt -q update - - - name: Install GCC 11 - if: ${{ startsWith(matrix.compiler, 'g++-11') }} - run: sudo apt install -y g++-11 - - name: Install GCC 10 - if: ${{ startsWith(matrix.compiler, 'g++-10') }} - run: sudo apt install -y g++-10 - - name: Install Clang 11 - if: ${{ startsWith(matrix.compiler, 'clang++-11') }} - run: sudo apt install -y clang-11 - - name: Install Clang 12 - if: ${{ startsWith(matrix.compiler, 'clang++-12') }} - run: sudo apt install -y clang-12 - - name: Install Clang 13 - if: ${{ startsWith(matrix.compiler, 'clang++-13') }} - run: sudo apt install -y clang-13 - - name: Install Clang 14 - if: ${{ startsWith(matrix.compiler, 'clang++-14') }} - run: sudo apt install -y clang-14 - + - name: Install clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh all + - name: Check clang version + run: clang++ --version - name: "Download dependencies" run: sudo apt install cmake ninja-build - name: "Cmake configure" - run: cmake --preset=prop-actions -S . -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - - name: "build " - run: cmake --build build/ --target "pyprop;prop_test" -- -j3 - - ubuntu_2004_cc_matrix_no_cuda: - strategy: - fail-fast: false - matrix: - cxx: [17] - build_type: ["RelWithDebInfo"] - compiler: - [ - "g++", - "clang++" - ] - name: "Ubuntu 20.04 (${{ matrix.compiler }}, C++${{ matrix.cxx }}, ${{matrix.build_type}})" - runs-on: ubuntu-20.04 - outputs: - id: "${{ matrix.compiler }} (C++${{ matrix.cxx }}, ${{ matrix.build_type }})" - steps: - - uses: actions/checkout@v3 - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: "ccache-ubuntu2004_no_cuda-${{ matrix.compiler }}-${{ matrix.cxx }}-${{ matrix.build_type }}" - max-size: 256M - - name: "update APT database" - run: sudo apt -q update - - name: Install GCC - if: ${{ startsWith(matrix.compiler, 'g++') }} - run: sudo apt install -y g++ - - name: Install Clang - if: ${{ startsWith(matrix.compiler, 'clang++') }} - run: sudo apt install -y clang - - name: "Download dependencies" - run: sudo apt install cmake ninja-build - - name: "Cmake configure" - run: cmake --preset=prop-actions -S . -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} + run: cmake --preset=prop-actions -S . -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - name: "build " run: cmake --build build/ --target "pyprop;prop_test" -- -j3 @@ -116,16 +57,12 @@ jobs: strategy: fail-fast: false matrix: - cxx: [17, 20] - build_type: ["Debug", "RelWithDebInfo"] - compiler: - [ - "g++-11" - ] - name: "Ubuntu 22.04 CUDA (${{ matrix.compiler }}, C++${{ matrix.cxx }}, ${{matrix.build_type}})" + cxx: [20] + build_type: ["Debug", "Release"] + name: "Ubuntu 22.04 CUDA (C++${{ matrix.cxx }}, ${{matrix.build_type}})" runs-on: ubuntu-22.04 outputs: - id: "${{ matrix.compiler }} (C++${{ matrix.cxx }}, ${{ matrix.build_type }})" + id: "(C++${{ matrix.cxx }}, ${{ matrix.build_type }})" steps: - uses: actions/checkout@v3 - name: ccache @@ -139,12 +76,15 @@ jobs: cuda: '12.1.0' - name: "update APT database" run: sudo apt -q update - - name: Install GCC 11 - if: ${{ startsWith(matrix.compiler, 'g++-11') }} - run: sudo apt install -y g++-11 + - name: Install clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh all + - name: "Download dependencies" run: sudo apt install cmake ninja-build - name: "Cmake configure" - run: cmake --preset=prop-cuda-actions -S . -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} + run: cmake --preset=prop-cuda-actions -S . -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - name: "build " run: cmake --build build/ --target "pyprop" -- -j3 diff --git a/CMakeLists.txt b/CMakeLists.txt index e7266b0..ecb7ef7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,10 +36,11 @@ FetchContent_MakeAvailable(spdlog) # ---- Add Kokkos ---- # Kokkos::kokkos + FetchContent_Declare( PyKokkosbase - GIT_REPOSITORY https://github.com/Yaraslaut/pykokkos-base.git - GIT_TAG ec5944a136d607a4b6fec36bb90dfcd11b36f877 + GIT_REPOSITORY https://github.com/kokkos/pykokkos-base.git + GIT_TAG b8694f5986eeeb7aacbf5d75430e3d9caa986629 ) FetchContent_MakeAvailable(PyKokkosbase) find_package(Python3 COMPONENTS Development) @@ -95,6 +96,9 @@ if(Prop_USE_SPDLOG) target_compile_definitions(prop_lib PUBLIC USE_SPDLOG) endif() +if(CMAKE_BUILD_TYPE STREQUAL "Release") + target_compile_options(prop_lib PUBLIC "-O3") +endif() target_link_libraries(prop_lib PUBLIC ${External_linked_libraries} diff --git a/CMakePresets.json b/CMakePresets.json index 61e729c..31c23c4 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -106,6 +106,7 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", "Kokkos_ENABLE_OPENMP": "OFF", + "CMAKE_CXX_STANDARD": "20", "Kokkos_ENABLE_CUDA" : "ON" } }, @@ -134,6 +135,7 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", "Kokkos_ENABLE_OPENMP": "ON", + "CMAKE_CXX_STANDARD": "20", "Kokkos_ENABLE_CUDA" : "ON" } } diff --git a/README.md b/README.md index 15a66d1..67db722 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ ![](logo/logo.png) -# This project is still under heavy development # prop @@ -13,7 +12,7 @@ data. Example command to build prop with openmp support, to compile with CUDA support, use `prop-cuda-debug` preset. ``` sh -cmake --preset=prop-openmp-debug +cmake --preset prop-openmp-debug cmake --build build --target pyprop ``` IMPORTANT: please specify `target` when building `prop` otherwise compilation time will be extremely large. @@ -32,21 +31,3 @@ python ./simple.py ``` - -## known issues -https://github.com/pybind/pybind11/issues/4606 - - -https://github.com/kokkos/pykokkos-base/issues/55 - - -https://github.com/NVIDIA/thrust/issues/1703 - - -https://github.com/llvm/llvm-project/issues/57544 - - -https://forums.developer.nvidia.com/t/strange-errors-after-system-gcc-upgraded-to-13-1-1/252441 - - -https://github.com/pybind/pybind11/issues/314 diff --git a/src/system.cpp b/src/system.cpp index 46db070..bd9020a 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -124,14 +124,18 @@ void System2D::addBlock(PMLRegionY& pml_block) pml_block._entity_id = _max_entity_id; const auto [x_offset, x_size, y_offset, y_size] = _geometry.getProperties(pml_block._box); + // OPENMP stuctured binding is not supported + auto x_offset_ = x_offset; + auto y_offset_ = y_offset; + auto policy = SimplePolicy2D({ 0, 0 }, { x_size, y_size }); auto entity_ind = _field._which_entity.view_host(); auto max_entity_ind = _max_entity_id; _field._which_entity.sync_host(); Kokkos::parallel_for( policy, KOKKOS_LAMBDA(const int& iinit, const int& jinit) { - const int i = iinit + x_offset; - const int j = jinit + y_offset; + const int i = iinit + x_offset_; + const int j = jinit + y_offset_; entity_ind(i, j) = max_entity_ind; }); pml_block._box._x.calcN(_space_step); diff --git a/src/types.h b/src/types.h index a63341a..b9d6ad6 100644 --- a/src/types.h +++ b/src/types.h @@ -28,8 +28,9 @@ namespace Prop { +constexpr double Const_pi = 3.14159265358979323846; constexpr double Const_epsilon0 = 8.85418782 * 1e-12; -constexpr double Const_mu0 = 4.0 * Kokkos::numbers::pi * 1e-7; +constexpr double Const_mu0 = 4.0 * Const_pi * 1e-7; constexpr double Const_c = 1.0; // 299792457.95971; constexpr double Const_standard_courant_factor = 1.0; // 84853; constexpr double Const_scaling_factor = 1.0; // 1e-6; // TODO @@ -59,7 +60,7 @@ struct Types { using view_type = GridData2D_dual; - using memory_space = std::conditional::value, + using memory_space = typename std::conditional::value, view_type::t_dev::memory_space, view_type::t_host::memory_space>::type;