From 7b6cd4e0b1d533785f4dc19454417cad30f00182 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Thu, 2 Jan 2025 13:00:27 +0800 Subject: [PATCH 01/31] Fix casting to fit Clang compiler. --- src/random/uniform_.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/random/uniform_.cpp b/src/random/uniform_.cpp index f4101886..113c1902 100644 --- a/src/random/uniform_.cpp +++ b/src/random/uniform_.cpp @@ -39,7 +39,7 @@ namespace cytnx { if (Tin.dtype() == Type.ComplexDouble) { Tin += cytnx_complex128{low, low}; } else if (Tin.dtype() == Type.ComplexFloat) { - Tin += cytnx_complex64{low, low}; + Tin += cytnx_complex64{static_cast(low), static_cast(low)}; } else if (Tin.dtype() == Type.Double) { Tin += low; } else if (Tin.dtype() == Type.Float) { From a9d753acd10dbf2cefbf583618e65e04a224f7d0 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Thu, 2 Jan 2025 13:12:30 +0800 Subject: [PATCH 02/31] Add macos test build in dev-master branch. --- .github/workflows/conda_build_macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/conda_build_macos.yml b/.github/workflows/conda_build_macos.yml index eb886692..db66c924 100644 --- a/.github/workflows/conda_build_macos.yml +++ b/.github/workflows/conda_build_macos.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - dev-master workflow_dispatch: From 48f854b7310afa7b754d90bbc627f183c6e8d4b9 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Thu, 2 Jan 2025 14:15:02 +0800 Subject: [PATCH 03/31] Test enable CMAKE_INTERPROCEDURAL_OPTIMIZATION --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75205615..d70869e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ project(CYTNX VERSION ${CYTNX_VERSION} LANGUAGES CXX C) # C++ uses link-time optimization anyway; this enables additionally -flto=auto, # for parallel compilation -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) add_library(cytnx STATIC) set_property(TARGET cytnx PROPERTY C_VISIBILITY_PRESET hidden) From da04d7b28bb1340db4003e7c23c6b6827c159e7b Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Thu, 2 Jan 2025 23:14:25 +0800 Subject: [PATCH 04/31] Test turn off pybind. --- .github/workflows/ci-cmake_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index d6bcd53f..aa6d27e2 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -45,7 +45,7 @@ jobs: - name: Configure CMake shell: bash -l {0} - run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on + run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=off -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on - name: Build shell: bash -l {0} From c3eab5fa788551acc67f743b4e910bc6b33b5ce2 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Thu, 2 Jan 2025 23:40:07 +0800 Subject: [PATCH 05/31] test turn off pybind --- .github/workflows/ci-cmake_tests.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index aa6d27e2..d6bcd53f 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -45,7 +45,7 @@ jobs: - name: Configure CMake shell: bash -l {0} - run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=off -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on + run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on - name: Build shell: bash -l {0} diff --git a/setup.py b/setup.py index 0ff4a3e6..c0a1ff46 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ def build_extension(self, ext): cfg = 'Debug' if self.debug else 'Release' build_args = ['--config', cfg] - cmake_args += ['-DBUILD_PYTHON=ON','-DUSE_CUDA=OFF','-DUSE_MKL=ON','-DUSE_HPTT=ON'] + cmake_args += ['-DBUILD_PYTHON=OFF','-DUSE_CUDA=OFF','-DUSE_MKL=ON','-DUSE_HPTT=ON'] cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] import multiprocessing From 35098ca043a44508dec5e1a2796fb08291b43193 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 00:03:17 +0800 Subject: [PATCH 06/31] revert to enable python wrapper. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c0a1ff46..0ff4a3e6 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ def build_extension(self, ext): cfg = 'Debug' if self.debug else 'Release' build_args = ['--config', cfg] - cmake_args += ['-DBUILD_PYTHON=OFF','-DUSE_CUDA=OFF','-DUSE_MKL=ON','-DUSE_HPTT=ON'] + cmake_args += ['-DBUILD_PYTHON=ON','-DUSE_CUDA=OFF','-DUSE_MKL=ON','-DUSE_HPTT=ON'] cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] import multiprocessing From 2d821c265d1cb017dfec77be90be17817f37d63e Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 10:42:00 +0800 Subject: [PATCH 07/31] Test, remove the enum_name cause the Clang compile error. --- pybind/cytnx.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pybind/cytnx.cpp b/pybind/cytnx.cpp index 0d84ae71..346cad27 100644 --- a/pybind/cytnx.cpp +++ b/pybind/cytnx.cpp @@ -59,11 +59,6 @@ PYBIND11_MODULE(cytnx, m) { bond_binding(m); py::add_ostream_redirect(m, "ostream_redirect"); - py::enum_ type_enum(m, "Type"); - for (std::size_t i = 0; i < N_Type; ++i) { - type_enum.value(Type.enum_name(i), static_cast(i)); - } - type_enum.export_values(); auto mdev = m.def_submodule("Device"); mdev.attr("cpu") = (cytnx_int64)cytnx::Device.cpu; From 0bfd43221477f76efc26007ff6960cc06a2f5bbb Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 10:42:40 +0800 Subject: [PATCH 08/31] Clang format --- pybind/cytnx.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/pybind/cytnx.cpp b/pybind/cytnx.cpp index 346cad27..9604c3d2 100644 --- a/pybind/cytnx.cpp +++ b/pybind/cytnx.cpp @@ -59,7 +59,6 @@ PYBIND11_MODULE(cytnx, m) { bond_binding(m); py::add_ostream_redirect(m, "ostream_redirect"); - auto mdev = m.def_submodule("Device"); mdev.attr("cpu") = (cytnx_int64)cytnx::Device.cpu; mdev.attr("cuda") = (cytnx_int64)cytnx::Device.cuda; From 3d1c576e4c974f4c74d9761e9f8087393689e531 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 11:49:38 +0800 Subject: [PATCH 09/31] Add inline in varialble template. --- include/Type.hpp | 52 ++++++++++++++++++++++++------------------------ pybind/cytnx.cpp | 6 ++++++ 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/include/Type.hpp b/include/Type.hpp index dc6c7eb6..a0e41e31 100644 --- a/include/Type.hpp +++ b/include/Type.hpp @@ -160,59 +160,59 @@ namespace cytnx { // The friendly name of each type template - constexpr char* Type_names = nullptr; + inline constexpr char* Type_names = nullptr; template <> - constexpr const char* Type_names = "Void"; + inline constexpr const char* Type_names = "Void"; template <> - constexpr const char* Type_names = "Complex Double (Complex Float64)"; + inline constexpr const char* Type_names = "Complex Double (Complex Float64)"; template <> - constexpr const char* Type_names = "Complex Float (Complex Float32)"; + inline constexpr const char* Type_names = "Complex Float (Complex Float32)"; template <> - constexpr const char* Type_names = "Double (Float64)"; + inline constexpr const char* Type_names = "Double (Float64)"; template <> - constexpr const char* Type_names = "Float (Float32)"; + inline constexpr const char* Type_names = "Float (Float32)"; template <> - constexpr const char* Type_names = "Int64"; + inline constexpr const char* Type_names = "Int64"; template <> - constexpr const char* Type_names = "Uint64"; + inline constexpr const char* Type_names = "Uint64"; template <> - constexpr const char* Type_names = "Int32"; + inline constexpr const char* Type_names = "Int32"; template <> - constexpr const char* Type_names = "Uint32"; + inline constexpr const char* Type_names = "Uint32"; template <> - constexpr const char* Type_names = "Int16"; + inline constexpr const char* Type_names = "Int16"; template <> - constexpr const char* Type_names = "Uint16"; + inline constexpr const char* Type_names = "Uint16"; template <> - constexpr const char* Type_names = "Bool"; + inline constexpr const char* Type_names = "Bool"; // The corresponding Python enumeration name template - constexpr char* Type_enum_name = nullptr; + inline constexpr char* Type_enum_name = nullptr; template <> - constexpr const char* Type_enum_name = "Void"; + inline constexpr const char* Type_enum_name = "Void"; template <> - constexpr const char* Type_enum_name = "ComplexDouble"; + inline constexpr const char* Type_enum_name = "ComplexDouble"; template <> - constexpr const char* Type_enum_name = "ComplexFloat"; + inline constexpr const char* Type_enum_name = "ComplexFloat"; template <> - constexpr const char* Type_enum_name = "Double"; + inline constexpr const char* Type_enum_name = "Double"; template <> - constexpr const char* Type_enum_name = "Float"; + inline constexpr const char* Type_enum_name = "Float"; template <> - constexpr const char* Type_enum_name = "Int64"; + inline constexpr const char* Type_enum_name = "Int64"; template <> - constexpr const char* Type_enum_name = "Uint64"; + inline constexpr const char* Type_enum_name = "Uint64"; template <> - constexpr const char* Type_enum_name = "Int32"; + inline constexpr const char* Type_enum_name = "Int32"; template <> - constexpr const char* Type_enum_name = "Uint32"; + inline constexpr const char* Type_enum_name = "Uint32"; template <> - constexpr const char* Type_enum_name = "Int16"; + inline constexpr const char* Type_enum_name = "Int16"; template <> - constexpr const char* Type_enum_name = "Uint16"; + inline constexpr const char* Type_enum_name = "Uint16"; template <> - constexpr const char* Type_enum_name = "Bool"; + inline constexpr const char* Type_enum_name = "Bool"; struct Type_struct { const char* name; // char* is OK here, it is only ever initialized from a string literal diff --git a/pybind/cytnx.cpp b/pybind/cytnx.cpp index 9604c3d2..0d84ae71 100644 --- a/pybind/cytnx.cpp +++ b/pybind/cytnx.cpp @@ -59,6 +59,12 @@ PYBIND11_MODULE(cytnx, m) { bond_binding(m); py::add_ostream_redirect(m, "ostream_redirect"); + py::enum_ type_enum(m, "Type"); + for (std::size_t i = 0; i < N_Type; ++i) { + type_enum.value(Type.enum_name(i), static_cast(i)); + } + type_enum.export_values(); + auto mdev = m.def_submodule("Device"); mdev.attr("cpu") = (cytnx_int64)cytnx::Device.cpu; mdev.attr("cuda") = (cytnx_int64)cytnx::Device.cuda; From e70b56f083607117e4db5c0799ba6139435fbb71 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 12:11:22 +0800 Subject: [PATCH 10/31] Add inline in varialble template. --- include/Type.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Type.hpp b/include/Type.hpp index a0e41e31..c8880af4 100644 --- a/include/Type.hpp +++ b/include/Type.hpp @@ -134,9 +134,9 @@ namespace cytnx { // type_size returns the sizeof(T) for the supported types. This is the same as // sizeof(T), except that size_type is 0. template - constexpr int type_size = sizeof(T); + inline constexpr int type_size = sizeof(T); template <> - constexpr int type_size = 0; + inline constexpr int type_size = 0; } // namespace internal // the list of supported types. The dtype() of an object is an index into this list. From afb2040f1b4ff15e7ff89afade9a5860fb6c8252 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 13:14:37 +0800 Subject: [PATCH 11/31] test mac build --- .github/workflows/ci-cmake_pytests.yml | 6 +++++- .github/workflows/ci-cmake_tests.yml | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-cmake_pytests.yml b/.github/workflows/ci-cmake_pytests.yml index 10b3d6c7..8386d523 100644 --- a/.github/workflows/ci-cmake_pytests.yml +++ b/.github/workflows/ci-cmake_pytests.yml @@ -5,7 +5,11 @@ on: jobs: BuildAndTest: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest] defaults: run: diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index d6bcd53f..c719a2be 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -3,13 +3,16 @@ name: Tests and Codecov on: pull_request: branches: - - master - - dev-master + - haoti/test_mac_build workflow_dispatch: jobs: BuildAndTest: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest] defaults: run: From 8d47056ecff728149da53860ee22c358b242319d Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 13:49:11 +0800 Subject: [PATCH 12/31] Fix run different comment in different platform. --- .github/workflows/ci-cmake_pytests.yml | 6 +----- .github/workflows/ci-cmake_tests.yml | 7 ++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cmake_pytests.yml b/.github/workflows/ci-cmake_pytests.yml index 8386d523..10b3d6c7 100644 --- a/.github/workflows/ci-cmake_pytests.yml +++ b/.github/workflows/ci-cmake_pytests.yml @@ -5,11 +5,7 @@ on: jobs: BuildAndTest: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ubuntu-latest, macos-latest] + runs-on: ubuntu-latest defaults: run: diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index c719a2be..cc1b9090 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -37,7 +37,12 @@ jobs: - name: Install dependencies shell: bash -l {0} run: | - mamba install _openmp_mutex=*=*_llvm cmake make boost git compilers numpy mkl mkl-include mkl-service pybind11 libblas=*=*mkl beartype + if [ "${{ runner.os }}" == "Linux" ]; then + mamba install _openmp_mutex=*=*_llvm + elif [ "${{ runner.os }}" == "macOS" ]; then + mamba install llvm-openmp + fi + mamba install cmake make boost git compilers numpy mkl mkl-include mkl-service pybind11 libblas=*=*mkl beartype python -m pip install gcovr mamba install gtest mamba install pytest pytest-cov From 3b27acf69b8df883b5476773fef9d94619c1c08d Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 13:59:05 +0800 Subject: [PATCH 13/31] instead of lscpu, using sysctl for macos to get the info of CPU. --- .github/workflows/ci-cmake_tests.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index cc1b9090..b1623210 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -49,7 +49,12 @@ jobs: - name: CPU info shell: bash -l {0} - run: lscpu + run: | + if [ "${{ runner.os }}" == "Linux" ]; then + lscpu + elif [ "${{ runner.os }}" == "macOS" ]; then + sysctl -a | grep machdep.cpu + fi - name: Configure CMake shell: bash -l {0} From 2d4806943f6d19a4dbcbfa1345032e07dac1002c Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 15:14:25 +0800 Subject: [PATCH 14/31] Turn off hptt fine tune in workflow, so same as test build. --- .github/workflows/ci-cmake_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index b1623210..6fe26f4f 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -58,7 +58,7 @@ jobs: - name: Configure CMake shell: bash -l {0} - run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on + run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=off -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on - name: Build shell: bash -l {0} From 953ed51c7de8bdc39244d246feec4ea17ce42c10 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 15:21:08 +0800 Subject: [PATCH 15/31] Add back correct branch. --- .github/workflows/ci-cmake_tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index 6fe26f4f..975df182 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -3,7 +3,8 @@ name: Tests and Codecov on: pull_request: branches: - - haoti/test_mac_build + - master + - dev-master workflow_dispatch: jobs: From 24e882039f29ee1202fbb341d90925ad3a44472f Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 15:33:15 +0800 Subject: [PATCH 16/31] Delete the branch dev-master in conda_build_macos workflow. --- .github/workflows/conda_build_macos.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/conda_build_macos.yml b/.github/workflows/conda_build_macos.yml index db66c924..eb886692 100644 --- a/.github/workflows/conda_build_macos.yml +++ b/.github/workflows/conda_build_macos.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - master - - dev-master workflow_dispatch: From b682af580cc9b2615569059d710a38868300fb99 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 16:47:11 +0800 Subject: [PATCH 17/31] Use channel conda forge. --- .github/workflows/ci-cmake_tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index 975df182..5b467d2a 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -38,6 +38,9 @@ jobs: - name: Install dependencies shell: bash -l {0} run: | + echo "Config Conda---------------------------------" + mamba install anaconda-client boa -c conda-forge + if [ "${{ runner.os }}" == "Linux" ]; then mamba install _openmp_mutex=*=*_llvm elif [ "${{ runner.os }}" == "macOS" ]; then @@ -59,7 +62,7 @@ jobs: - name: Configure CMake shell: bash -l {0} - run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=off -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on + run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on - name: Build shell: bash -l {0} From d837a1a7f602926e1fd0257e901afbc897f19d36 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 22:13:45 +0800 Subject: [PATCH 18/31] Disable ctest on Macos workflos. --- .github/workflows/ci-cmake_tests.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index 5b467d2a..35650e6f 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -62,7 +62,12 @@ jobs: - name: Configure CMake shell: bash -l {0} - run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on + run: | + if [ "${{ runner.os }}" == "Linux" ]; then + cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on + elif [ "${{ runner.os }}" == "macOS" ]; then + cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=off + fi - name: Build shell: bash -l {0} From 80bb082e2105c48483f8de8812c4271ad2266444 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 23:06:16 +0800 Subject: [PATCH 19/31] Fix workflow file incoorect syntax. --- .github/workflows/ci-cmake_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index 35650e6f..93ea55f6 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -64,9 +64,9 @@ jobs: shell: bash -l {0} run: | if [ "${{ runner.os }}" == "Linux" ]; then - cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on + cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on elif [ "${{ runner.os }}" == "macOS" ]; then - cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=off + cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=off fi - name: Build From 8cb8215bc87a8e11254a8112067a2bd928ac05cc Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 23:23:04 +0800 Subject: [PATCH 20/31] Disable macos BuildAndTest. 1. The test building still have some issue. It need too long time to build. 2. We still not support gtest for macos. --- .github/workflows/ci-cmake_tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index 93ea55f6..9e6cc402 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -13,7 +13,8 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest] + #os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] defaults: run: From b4281c9124b32aadb7ca4e39d29753d28529760b Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 23:26:12 +0800 Subject: [PATCH 21/31] enabel . --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d70869e3..75205615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ project(CYTNX VERSION ${CYTNX_VERSION} LANGUAGES CXX C) # C++ uses link-time optimization anyway; this enables additionally -flto=auto, # for parallel compilation -#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) add_library(cytnx STATIC) set_property(TARGET cytnx PROPERTY C_VISIBILITY_PRESET hidden) From 6c328c30d340b0601cf7084faeaf017dd89ac17e Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 23:31:33 +0800 Subject: [PATCH 22/31] Revert workflow to original one. --- .github/workflows/ci-cmake_tests.yml | 37 +++------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index 9e6cc402..220bc8c9 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -1,5 +1,4 @@ name: Tests and Codecov - on: pull_request: branches: @@ -9,20 +8,13 @@ on: jobs: BuildAndTest: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - #os: [ubuntu-latest, macos-latest] - os: [ubuntu-latest] + runs-on: ubuntu-latest defaults: run: shell: bash -l {0} - steps: - uses: actions/checkout@v3 - - uses: conda-incubator/setup-miniconda@v2 with: # Specify python version your environment will have. Remember to quote this, or @@ -35,40 +27,19 @@ jobs: # prone than conda while being completely compatible with the conda CLI use-mamba: true mamba-version: "*" - - name: Install dependencies shell: bash -l {0} run: | - echo "Config Conda---------------------------------" - mamba install anaconda-client boa -c conda-forge - - if [ "${{ runner.os }}" == "Linux" ]; then - mamba install _openmp_mutex=*=*_llvm - elif [ "${{ runner.os }}" == "macOS" ]; then - mamba install llvm-openmp - fi - mamba install cmake make boost git compilers numpy mkl mkl-include mkl-service pybind11 libblas=*=*mkl beartype + mamba install _openmp_mutex=*=*_llvm cmake make boost git compilers numpy mkl mkl-include mkl-service pybind11 libblas=*=*mkl beartype python -m pip install gcovr mamba install gtest mamba install pytest pytest-cov - - name: CPU info shell: bash -l {0} - run: | - if [ "${{ runner.os }}" == "Linux" ]; then - lscpu - elif [ "${{ runner.os }}" == "macOS" ]; then - sysctl -a | grep machdep.cpu - fi - + run: lscpu - name: Configure CMake shell: bash -l {0} - run: | - if [ "${{ runner.os }}" == "Linux" ]; then - cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on - elif [ "${{ runner.os }}" == "macOS" ]; then - cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=off - fi + run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on - name: Build shell: bash -l {0} From e63f78a72f39c82a0314269977b78d0b937326d2 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 23:33:38 +0800 Subject: [PATCH 23/31] Revert workflow to original one. --- .github/workflows/ci-cmake_tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci-cmake_tests.yml b/.github/workflows/ci-cmake_tests.yml index 220bc8c9..d6bcd53f 100644 --- a/.github/workflows/ci-cmake_tests.yml +++ b/.github/workflows/ci-cmake_tests.yml @@ -1,4 +1,5 @@ name: Tests and Codecov + on: pull_request: branches: @@ -13,8 +14,10 @@ jobs: defaults: run: shell: bash -l {0} + steps: - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 with: # Specify python version your environment will have. Remember to quote this, or @@ -27,6 +30,7 @@ jobs: # prone than conda while being completely compatible with the conda CLI use-mamba: true mamba-version: "*" + - name: Install dependencies shell: bash -l {0} run: | @@ -34,9 +38,11 @@ jobs: python -m pip install gcovr mamba install gtest mamba install pytest pytest-cov + - name: CPU info shell: bash -l {0} run: lscpu + - name: Configure CMake shell: bash -l {0} run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on From d289ceeef7b2edcad4dbb32b15548b44f5ec5f24 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 23:37:12 +0800 Subject: [PATCH 24/31] Add dev-master for macos. --- .github/workflows/conda_build_macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/conda_build_macos.yml b/.github/workflows/conda_build_macos.yml index eb886692..db66c924 100644 --- a/.github/workflows/conda_build_macos.yml +++ b/.github/workflows/conda_build_macos.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - dev-master workflow_dispatch: From 87ef0c741132df97dafd3a5662207deb7618881d Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Fri, 3 Jan 2025 23:55:53 +0800 Subject: [PATCH 25/31] Disable since it will build failed on macos. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75205615..d70869e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ project(CYTNX VERSION ${CYTNX_VERSION} LANGUAGES CXX C) # C++ uses link-time optimization anyway; this enables additionally -flto=auto, # for parallel compilation -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) add_library(cytnx STATIC) set_property(TARGET cytnx PROPERTY C_VISIBILITY_PRESET hidden) From 9307805a6f41bb09aaa8cc0367d9ffc71eeeb441 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Sat, 4 Jan 2025 00:53:47 +0800 Subject: [PATCH 26/31] Revert, don't need for dev-master branch. --- .github/workflows/conda_build_macos.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/conda_build_macos.yml b/.github/workflows/conda_build_macos.yml index db66c924..eb886692 100644 --- a/.github/workflows/conda_build_macos.yml +++ b/.github/workflows/conda_build_macos.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - master - - dev-master workflow_dispatch: From e20f9b3fb5f76429de44e63fd7d8c7dccd9dabcd Mon Sep 17 00:00:00 2001 From: hunghaoti <115763164+hunghaoti@users.noreply.github.com> Date: Sat, 4 Jan 2025 10:26:47 +0800 Subject: [PATCH 27/31] Refine Readme examle code. --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 6b7cc4dc..07aeee09 100644 --- a/Readme.md +++ b/Readme.md @@ -89,7 +89,7 @@ Available types are : ```c++ Storage A(400,Type.Double); for(int i=0;i<400;i++) -A.at(i) = i; + A.at(i) = i; Storage B = A; // A and B share same memory, this is similar to Python From 5062df13dadd12582975980d45186cdc33edff43 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Sat, 4 Jan 2025 10:31:48 +0800 Subject: [PATCH 28/31] Enable on linux platform. --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d70869e3..88e732ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,11 @@ project(CYTNX VERSION ${CYTNX_VERSION} LANGUAGES CXX C) # C++ uses link-time optimization anyway; this enables additionally -flto=auto, # for parallel compilation -#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +IF (APPLE) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE) +ELSE () + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +ENDIF () add_library(cytnx STATIC) set_property(TARGET cytnx PROPERTY C_VISIBILITY_PRESET hidden) From 05f07dcdae8bb2748973c21c4ab2e81a65a6727e Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Sat, 4 Jan 2025 10:34:00 +0800 Subject: [PATCH 29/31] Enable macos building test temporarily. --- .github/workflows/conda_build_macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/conda_build_macos.yml b/.github/workflows/conda_build_macos.yml index eb886692..db66c924 100644 --- a/.github/workflows/conda_build_macos.yml +++ b/.github/workflows/conda_build_macos.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - dev-master workflow_dispatch: From 55e51bd0c6ace620a56dd53ab3d28221358b8623 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Sat, 4 Jan 2025 10:41:45 +0800 Subject: [PATCH 30/31] Enable macos building test temporarily. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88e732ca..820361b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,8 @@ project(CYTNX VERSION ${CYTNX_VERSION} LANGUAGES CXX C) # C++ uses link-time optimization anyway; this enables additionally -flto=auto, # for parallel compilation +# It cannot enable on MacOS since it cuase bulding error when linking the library libcytnx.a. +# Error message: Error running link command: no such file or directorymake[2]: *** [CMakeFiles/cytnx.dir/build.make:3109: libcytnx.a] IF (APPLE) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE) ELSE () From 9c1d8f96c4ddf3d539284c2c6d62daf059123839 Mon Sep 17 00:00:00 2001 From: hunghaoti Date: Sat, 4 Jan 2025 11:33:35 +0800 Subject: [PATCH 31/31] Remove macos bulding workflor in branch dev-master. --- .github/workflows/conda_build_macos.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/conda_build_macos.yml b/.github/workflows/conda_build_macos.yml index db66c924..eb886692 100644 --- a/.github/workflows/conda_build_macos.yml +++ b/.github/workflows/conda_build_macos.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - master - - dev-master workflow_dispatch: