Skip to content

Commit

Permalink
Adds a GitHub CI step for OpenMP and some formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sterrettm2 committed May 22, 2024
1 parent 71a9cfa commit 5c81fb1
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 28 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,38 @@ jobs:
- name: Run test suite on SPR
run: sde -spr -- ./builddir/testexe

SKX-SKL-openmp:

runs-on: intel-ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install dependencies
run: |
sudo apt update
sudo apt -y install g++-10 libgtest-dev meson curl git
- name: Install Intel SDE
run: |
curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/784319/sde-external-9.24.0-2023-07-13-lin.tar.xz
mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/
sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde
- name: Build
env:
CXX: g++-10
run: |
make clean
meson setup -Dbuild_tests=true -Duse_openmp=true --warnlevel 2 --werror --buildtype release builddir
cd builddir
ninja
- name: Run test suite on SKX and SKL
run: |
sde -skx -- ./builddir/testexe
sde -skl -- ./builddir/testexe
SPR-gcc13-special-cases:

runs-on: intel-ubuntu-latest
Expand Down
76 changes: 48 additions & 28 deletions src/xss-common-keyvaluesort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,29 +393,46 @@ X86_SIMD_SORT_INLINE void kvsort_(type1_t *keys,
arrsize_t pivot_index = kvpartition_unrolled<vtype1, vtype2, 4>(
keys, indexes, left, right + 1, pivot, &smallest, &biggest);


#if defined(XSS_USE_OPENMP) && defined(_OPENMP)
if (pivot != smallest) {
bool parallelLeft = (pivot_index - left) > task_threshold;
if (parallelLeft){
#pragma omp task if(parallelLeft)
kvsort_<vtype1, vtype2>(
keys, indexes, left, pivot_index - 1, max_iters - 1, task_threshold);
}else{
kvsort_<vtype1, vtype2>(
keys, indexes, left, pivot_index - 1, max_iters - 1, task_threshold);
bool parallel_left = (pivot_index - left) > task_threshold;
if (parallel_left) {
#pragma omp task
kvsort_<vtype1, vtype2>(keys,
indexes,
left,
pivot_index - 1,
max_iters - 1,
task_threshold);
}
else {
kvsort_<vtype1, vtype2>(keys,
indexes,
left,
pivot_index - 1,
max_iters - 1,
task_threshold);
}
}
if (pivot != biggest) {
bool parallelRight = (right - pivot_index) > task_threshold;

if (parallelRight){
#pragma omp task if(parallelRight)
kvsort_<vtype1, vtype2>(
keys, indexes, pivot_index, right, max_iters - 1, task_threshold);
}else{
kvsort_<vtype1, vtype2>(
keys, indexes, pivot_index, right, max_iters - 1, task_threshold);
bool parallel_right = (right - pivot_index) > task_threshold;

if (parallel_right) {
#pragma omp task
kvsort_<vtype1, vtype2>(keys,
indexes,
pivot_index,
right,
max_iters - 1,
task_threshold);
}
else {
kvsort_<vtype1, vtype2>(keys,
indexes,
pivot_index,
right,
max_iters - 1,
task_threshold);
}
}
#else
Expand Down Expand Up @@ -518,19 +535,22 @@ X86_SIMD_SORT_INLINE void xss_qsort_kv(
}

#if defined(XSS_USE_OPENMP) && defined(_OPENMP)
bool useParallel = arrsize > 10000;
arrsize_t taskThreshold = std::max((arrsize_t) 10000, arrsize / 100);
if (useParallel){
#pragma omp parallel
#pragma omp single
kvsort_<keytype, valtype>(keys, indexes, 0, arrsize - 1, maxiters, taskThreshold);
}else{
kvsort_<keytype, valtype>(keys, indexes, 0, arrsize - 1, maxiters, taskThreshold);
bool use_parallel = arrsize > 10000;
arrsize_t task_threshold = std::max((arrsize_t)10000, arrsize / 100);
if (use_parallel) {
#pragma omp parallel
#pragma omp single
kvsort_<keytype, valtype>(
keys, indexes, 0, arrsize - 1, maxiters, task_threshold);
}
else {
kvsort_<keytype, valtype>(
keys, indexes, 0, arrsize - 1, maxiters, task_threshold);
}
#else
kvsort_<keytype, valtype>(keys, indexes, 0, arrsize - 1, maxiters, 0);
#endif
#endif

replace_inf_with_nan(keys, arrsize, nan_count);

if (descending) {
Expand Down

0 comments on commit 5c81fb1

Please sign in to comment.