From 8a735821038d6dc1f85eda94bff7035dac9eb6c8 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:12:51 -0400 Subject: [PATCH 1/9] one line fix --- .github/workflows/openmp-macos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/openmp-macos.yaml b/.github/workflows/openmp-macos.yaml index bcb29d97..db51a1fc 100644 --- a/.github/workflows/openmp-macos.yaml +++ b/.github/workflows/openmp-macos.yaml @@ -14,6 +14,7 @@ jobs: # os level stuff set -x brew install googletest llvm + echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile - name: install BLAS++ run: | From bc8c7200eeafa8ae7861670ee3b44c54b4d46983 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:23:55 -0400 Subject: [PATCH 2/9] another attempt --- .github/workflows/openmp-macos.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/openmp-macos.yaml b/.github/workflows/openmp-macos.yaml index db51a1fc..b8916d51 100644 --- a/.github/workflows/openmp-macos.yaml +++ b/.github/workflows/openmp-macos.yaml @@ -15,6 +15,8 @@ jobs: set -x brew install googletest llvm echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile + export PATH="/opt/homebrew/opt/llvm/bin:$PATH + # ^ For the current bash session - name: install BLAS++ run: | From 2303e7a7d5a2a5ba007882146d622cdc367ed4a6 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:25:43 -0400 Subject: [PATCH 3/9] fix typo --- .github/workflows/openmp-macos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/openmp-macos.yaml b/.github/workflows/openmp-macos.yaml index b8916d51..0eb0aaba 100644 --- a/.github/workflows/openmp-macos.yaml +++ b/.github/workflows/openmp-macos.yaml @@ -15,7 +15,7 @@ jobs: set -x brew install googletest llvm echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile - export PATH="/opt/homebrew/opt/llvm/bin:$PATH + export PATH="/opt/homebrew/opt/llvm/bin:$PATH" # ^ For the current bash session - name: install BLAS++ From 7e80d19cb47bfe7e703813f19b843dedc617b9e1 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:28:56 -0400 Subject: [PATCH 4/9] another attempt --- .github/workflows/openmp-macos.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/openmp-macos.yaml b/.github/workflows/openmp-macos.yaml index 0eb0aaba..515c331c 100644 --- a/.github/workflows/openmp-macos.yaml +++ b/.github/workflows/openmp-macos.yaml @@ -14,9 +14,10 @@ jobs: # os level stuff set -x brew install googletest llvm - echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile - export PATH="/opt/homebrew/opt/llvm/bin:$PATH" - # ^ For the current bash session + export CXX=/opt/homebrew/opt/llvm/bin/clang++ + export CC=/opt/homebrew/opt/llvm/bin/clang + export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" + export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" - name: install BLAS++ run: | From ab223d53b5895d03573d747e738365594f98e21a Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:31:39 -0400 Subject: [PATCH 5/9] That was embarassing --- .github/workflows/openmp-macos.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/openmp-macos.yaml b/.github/workflows/openmp-macos.yaml index 515c331c..e510ce00 100644 --- a/.github/workflows/openmp-macos.yaml +++ b/.github/workflows/openmp-macos.yaml @@ -14,10 +14,6 @@ jobs: # os level stuff set -x brew install googletest llvm - export CXX=/opt/homebrew/opt/llvm/bin/clang++ - export CC=/opt/homebrew/opt/llvm/bin/clang - export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" - export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" - name: install BLAS++ run: | @@ -26,8 +22,8 @@ jobs: mkdir blaspp-build cd blaspp-build cmake \ - -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ \ - -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \ + -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \ + -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=`pwd`/../blaspp-install \ -Dbuild_tests=OFF \ @@ -48,8 +44,8 @@ jobs: mkdir RandBLAS-build cd RandBLAS-build cmake \ - -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ \ - -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \ + -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \ + -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \ -DCMAKE_BUILD_TYPE=Release \ -Dblaspp_DIR=`pwd`/../blaspp-install/lib/cmake/blaspp/ \ -DRandom123_DIR=`pwd`/../Random123-install/include/ \ From 9781e587882d44fdf019117606aaa53a50205d2e Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:38:21 -0400 Subject: [PATCH 6/9] dedicated macos-13 runner for openmp --- .github/workflows/openmp-macos-13.yaml | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/openmp-macos-13.yaml diff --git a/.github/workflows/openmp-macos-13.yaml b/.github/workflows/openmp-macos-13.yaml new file mode 100644 index 00000000..84d0eb25 --- /dev/null +++ b/.github/workflows/openmp-macos-13.yaml @@ -0,0 +1,55 @@ +name: openmp-macos +on: + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: macos-13 + steps: + - uses: actions/checkout@v2 + + - name: configure OS + run: | + # os level stuff + set -x + brew install googletest llvm + + - name: install BLAS++ + run: | + cd .. + git clone https://github.com/icl-utk-edu/blaspp.git + mkdir blaspp-build + cd blaspp-build + cmake \ + -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ \ + -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=`pwd`/../blaspp-install \ + -Dbuild_tests=OFF \ + ../blaspp + make -j2 install + + - name: install Random123 + run: | + cd .. + git clone https://github.com/DEShawResearch/Random123.git + cd Random123/ + mkdir -p `pwd`/../Random123-install/include + cp -rp include/Random123 `pwd`/../Random123-install/include/ + + - name: build and test RandBLAS (release) + run: | + cd .. + mkdir RandBLAS-build + cd RandBLAS-build + cmake \ + -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ \ + -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \ + -DCMAKE_BUILD_TYPE=Release \ + -Dblaspp_DIR=`pwd`/../blaspp-install/lib/cmake/blaspp/ \ + -DRandom123_DIR=`pwd`/../Random123-install/include/ \ + -DCMAKE_INSTALL_PREFIX=`pwd`/../RandBLAS-install \ + ../RandBLAS + make -j2 install + ctest --output-on-failure From 45534547a742a5634281ffc314fd25c9a2bda179 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:39:38 -0400 Subject: [PATCH 7/9] rename workflows --- .github/workflows/openmp-macos-13.yaml | 2 +- .github/workflows/openmp-macos.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/openmp-macos-13.yaml b/.github/workflows/openmp-macos-13.yaml index 84d0eb25..4cd576c3 100644 --- a/.github/workflows/openmp-macos-13.yaml +++ b/.github/workflows/openmp-macos-13.yaml @@ -1,4 +1,4 @@ -name: openmp-macos +name: openmp-macos-13 on: pull_request: workflow_dispatch: diff --git a/.github/workflows/openmp-macos.yaml b/.github/workflows/openmp-macos.yaml index e510ce00..fba16aa6 100644 --- a/.github/workflows/openmp-macos.yaml +++ b/.github/workflows/openmp-macos.yaml @@ -1,4 +1,4 @@ -name: openmp-macos +name: openmp-macos-latest on: pull_request: workflow_dispatch: From 8991eba38d0e3264d587e5425ab83eb00fa1effb Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:51:25 -0400 Subject: [PATCH 8/9] resolve compiler warnings stemming from allocation of dynamically sized array on the stack. Fix some code formatting / style issues. --- RandBLAS/dense_skops.hh | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/RandBLAS/dense_skops.hh b/RandBLAS/dense_skops.hh index a79c9549..d84f8914 100644 --- a/RandBLAS/dense_skops.hh +++ b/RandBLAS/dense_skops.hh @@ -332,38 +332,40 @@ static RNGState fill_dense_submat_impl( } randblas_require(n_cols >= n_scols); RNG rng; - typename RNG::ctr_type c = seed.counter; - typename RNG::key_type k = seed.key; + using CTR_t = typename RNG::ctr_type; + using KEY_t = typename RNG::key_type; + CTR_t c = seed.counter; + KEY_t k = seed.key; int64_t pad = 0; // ^ computed such that n_cols+pad is divisible by RNG::static_size - if (n_cols % RNG::ctr_type::static_size != 0) { - pad = RNG::ctr_type::static_size - n_cols % RNG::ctr_type::static_size; + if (n_cols % CTR_t::static_size != 0) { + pad = CTR_t::static_size - n_cols % CTR_t::static_size; } int64_t n_cols_padded = n_cols + pad; - // ^ smallest number of columns, greater than or equal to n_cols, that would be divisible by RNG::ctr_type::static_size + // ^ smallest number of columns, greater than or equal to n_cols, that would be divisible by CTR_t::static_size int64_t ptr_padded = ptr + ptr / n_cols * pad; // ^ ptr corresponding to the padded matrix - int64_t r0_padded = ptr_padded / RNG::ctr_type::static_size; + int64_t r0_padded = ptr_padded / CTR_t::static_size; // ^ starting counter corresponding to ptr_padded - int64_t r1_padded = (ptr_padded + n_scols - 1) / RNG::ctr_type::static_size; + int64_t r1_padded = (ptr_padded + n_scols - 1) / CTR_t::static_size; // ^ ending counter corresponding to ptr of the last element of the row - int64_t ctr_gap = n_cols_padded / RNG::ctr_type::static_size; + int64_t ctr_gap = n_cols_padded / CTR_t::static_size; // ^ number of counters between the first counter of the row to the first counter of the next row; - int64_t s0 = ptr_padded % RNG::ctr_type::static_size; - int64_t e1 = (ptr_padded + n_scols - 1) % RNG::ctr_type::static_size; + int64_t s0 = ptr_padded % CTR_t::static_size; + int64_t e1 = (ptr_padded + n_scols - 1) % CTR_t::static_size; int64_t num_thrds = 1; -#if defined(RandBLAS_HAS_OpenMP) + #if defined(RandBLAS_HAS_OpenMP) #pragma omp parallel { num_thrds = omp_get_num_threads(); } -#endif + #endif //Instead of using thrd_arr just initialize ctr_arr to be zero counters; - typename RNG::ctr_type ctr_arr[num_thrds]; + CTR_t *ctr_arr = new CTR_t[num_thrds]; for (int i = 0; i < num_thrds; i++) { ctr_arr[i] = c; } @@ -381,9 +383,9 @@ static RNGState fill_dense_submat_impl( #pragma omp for for (int row = 0; row < n_srows; row++) { - #if defined(RandBLAS_HAS_OpenMP) - thrd = omp_get_thread_num(); - #endif + #if defined(RandBLAS_HAS_OpenMP) + thrd = omp_get_thread_num(); + #endif ind = 0; r0 = r0_padded + ctr_gap*row; @@ -392,7 +394,7 @@ static RNGState fill_dense_submat_impl( cc.incr(r0 - prev); prev = r0; auto rv = OP::generate(rng, cc, k); - int64_t range = (r1 > r0)? RNG::ctr_type::static_size-1 : e1; + int64_t range = (r1 > r0)? CTR_t::static_size - 1 : e1; for (i = s0; i <= range; i++) { smat[ind + row * lda] = rv[i]; ind++; @@ -403,7 +405,7 @@ static RNGState fill_dense_submat_impl( cc.incr(); prev++; rv = OP::generate(rng, cc, k); - for (i = 0; i < RNG::ctr_type::static_size; i++) { + for (i = 0; i < CTR_t::static_size; i++) { smat[ind + row * lda] = rv[i]; ind++; } @@ -426,12 +428,13 @@ static RNGState fill_dense_submat_impl( } //finds the largest counter in the counter array - typename RNG::ctr_type max_c = ctr_arr[0]; + CTR_t max_c = ctr_arr[0]; for (int i = 1; i < num_thrds; i++) { if (compare_ctr(ctr_arr[i], max_c)) { max_c = ctr_arr[i]; } } + delete [] ctr_arr; max_c.incr(); return RNGState {max_c, k}; From d5f5346ff8cf5004f0ac7b1e359532d87afad858 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 29 May 2024 06:56:28 -0400 Subject: [PATCH 9/9] Fix another instance of stack-allocated dynamically-sized array --- test/test_dense_skops/test_construction.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_dense_skops/test_construction.cc b/test/test_dense_skops/test_construction.cc index a6005a8a..5520a5c4 100644 --- a/test/test_dense_skops/test_construction.cc +++ b/test/test_dense_skops/test_construction.cc @@ -461,7 +461,7 @@ class TestStateUpdate : public ::testing::Test RandBLAS::DenseDistName dn ) { int total = 0; - int buff[n_rows*n_cols]; + int *buff = new int[n_rows*n_cols]; auto state = RandBLAS::RNGState(key); auto state_copy = RandBLAS::RNGState(key); @@ -486,6 +486,7 @@ class TestStateUpdate : public ::testing::Test } ASSERT_TRUE(total == 0); + delete [] buff; } };