Skip to content

Commit

Permalink
update benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
weilewei committed Mar 2, 2023
1 parent 7d406ac commit 0a91861
Show file tree
Hide file tree
Showing 88 changed files with 31,464 additions and 115 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ project(parSTL LANGUAGES CXX C)

set(CMAKE_BUILD_TYPE Release)

set(HPX_DIR "/global/homes/w/wwei/install/hpx_Release/lib64/cmake/HPX/")
set(Kokkos_DIR "/global/homes/w/wwei/install/kokkos_cpu/lib64/cmake/Kokkos/")
set(TBB_DIR "/global/u2/w/wwei/src/spack/opt/spack/linux-sles15-zen3/gcc-11.2.0/intel-tbb-2021.7.0-2ls74bj4nkv3twgy2e5mn4xa4ovpyl6z/lib64/cmake/TBB/")
# set(TBB_DIR "/global/homes/w/wwei/install/oneTBB/lib64/cmake/TBB/")
# set(HPX_DIR "/global/homes/w/wwei/install/hpx_gcc_Release/lib64/cmake/HPX/")
# # set(Kokkos_DIR "/global/homes/w/wwei/install/kokkos_gcc_openmp/lib64/cmake/Kokkos/")
# set(Kokkos_DIR "/global/homes/w/wwei/install/kokkos_gcc_threads/lib64/cmake/Kokkos/")

# set(HPX_DIR "/global/homes/w/wwei/install/hpx_clang_Release/lib64/cmake/HPX/")
# set(Kokkos_DIR "/global/homes/w/wwei/install/kokkos_clang_threads//lib64/cmake/Kokkos/")
# # set(Kokkos_DIR "/global/homes/w/wwei/install/kokkos_clang_openmp//lib64/cmake/Kokkos/")
# set(TBB_DIR "/global/homes/w/wwei/install/oneTBB_clang/lib64/cmake/TBB/")

include_directories(commons)

add_subdirectory(std)
add_subdirectory(stdTbb)
add_subdirectory(hpx)
add_subdirectory(kokkos)
# add_subdirectory(nvc)
add_subdirectory(gnu)
add_subdirectory(taskflow)

4 changes: 2 additions & 2 deletions commons/commons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ std::random_device rd; // only used once to initialise (seed) engine
std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case)
std::uniform_int_distribution<int> uni(0,65535); // guaranteed unbiased

constexpr long long TEST_SIZE = 500000000;
// constexpr long long TEST_SIZE = 500000000;
// constexpr long long TEST_SIZE = 25000000;
constexpr long long REPEAT = 10;
constexpr long long REPEAT = 5;

template <typename Func>
void getExecutionTime(const std::string& title, Func func){ // (4)
Expand Down
19 changes: 15 additions & 4 deletions gnu/gnuPar.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <commons.hpp>
#include <parallel/algorithm>

int main(){
std::vector<double> workVec(TEST_SIZE);
for (size_t i =0; i < TEST_SIZE; ++i) {
void runTaskSize(const long long length) {
std::vector<double> workVec(length);
for (size_t i =0; i < length; ++i) {
workVec[i] = uni(rng);
}

Expand All @@ -18,5 +18,16 @@ int main(){
__gnu_parallel::sort(workVec.begin(), workVec.end());});

std::cout << '\n';

}


int main(int argc, char** argv){
long long length;

char *a = argv[1];
length = atoll(a);

std::cout << "running experiment with size of " + std::to_string(length) << "\n";

runTaskSize(length);
}
32 changes: 14 additions & 18 deletions hpx/hpxPar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
#include <hpx/iostream.hpp>
#include <hpx/algorithm.hpp>
#include <hpx/execution.hpp>
#include <hpx/parallel/datapar.hpp>

int main(){
std::vector<double> workVec(TEST_SIZE);
for (size_t i =0; i < TEST_SIZE; ++i) {
void runTaskSize(const long long length){
std::vector<double> workVec(length);
for (size_t i =0; i < length; ++i) {
workVec[i] = uni(rng);
}

Expand All @@ -32,20 +31,6 @@ int main(){
[](double arg){ return std::tan(arg); }
);
});

// getExecutionTime("transform hpx::execution::simd", [workVec]() mutable { // (8)
// hpx::transform(hpx::execution::simd, workVec.begin(), workVec.end(), // (3)
// workVec.begin(),
// [](double arg){ return std::tan(arg); }
// );
// });
//
// getExecutionTime("transform hpx::execution::par_simd", [workVec]() mutable { // (8)
// hpx::transform(hpx::execution::par_simd, workVec.begin(), workVec.end(), // (3)
// workVec.begin(),
// [](double arg){ return std::tan(arg); }
// );
// });

getExecutionTime("sort hpx::execution::seq", [workVec]() mutable {
hpx::sort(hpx::execution::seq, workVec.begin(), workVec.end());
Expand All @@ -60,4 +45,15 @@ int main(){
});

std::cout << '\n';
}

int main(int argc, char** argv){
long long length;

char *a = argv[1];
length = atoll(a);

std::cout << "running experiment with size of " + std::to_string(length) << "\n";

runTaskSize(length);
}
94 changes: 47 additions & 47 deletions kokkos/kokkosPar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,54 @@
#include<Kokkos_Core.hpp>
#include <Kokkos_Sort.hpp>

void runTaskSize(const long long length) {
Kokkos::View<double*> workVec ("x", length);

// Prevent touching workVec in serial so we don't mess up data affinity
std::vector<double> workVecData(length);
for (long long i = 0 ; i < length; ++i)
workVecData[i] = uni(rng);

Kokkos::parallel_for(length, KOKKOS_LAMBDA(const int& i)
{ workVec(i) = workVecData[i]; });

auto test = [=]() {
Kokkos::parallel_for("kokkos::parallel_for transform optimized version",
Kokkos::RangePolicy<Kokkos::IndexType<int>, Kokkos::Schedule<Kokkos::Dynamic>>
(0, length), KOKKOS_LAMBDA (const int& i) {
workVec(i) = std::tan(workVec(i));
});
};

test();
getExecutionTime("kokkos::parallel_for transform optimized version", test);
}

int main(int argc, char* argv[]) {
Kokkos::initialize(argc,argv);
Kokkos::initialize(argc, argv);

{
Kokkos::View<double*> workVec ("x", TEST_SIZE);

for (long long i = 0 ; i < TEST_SIZE; ++i)
workVec(i) = uni(rng);

getExecutionTime("kokkos::parallel_for transform", [&workVec]() mutable { // (6)
Kokkos::parallel_for("kokkos::parallel_for transform", TEST_SIZE, KOKKOS_LAMBDA (const int& i) {
workVec(i) = std::tan(workVec(i) );
});
});
}

{
Kokkos::View<double*> workVec ("x", TEST_SIZE);

// Prevent touching workVec in serial so we don't mess up data affinity
std::vector<double> workVecData(TEST_SIZE);
for (long long i = 0 ; i < TEST_SIZE; ++i)
workVecData[i] = uni(rng);

Kokkos::parallel_for(TEST_SIZE, KOKKOS_LAMBDA(const int& i) { workVec(i) = workVecData[i]; });

auto test = [=]() {
Kokkos::parallel_for("kokkos::parallel_for transform optimized version", Kokkos::RangePolicy<Kokkos::IndexType<int>, Kokkos::Schedule<Kokkos::Dynamic>>(0, TEST_SIZE), KOKKOS_LAMBDA (const int& i) {
workVec(i) = std::tan(workVec(i));
});
};

test();
getExecutionTime("kokkos::parallel_for transform optimized version", test);
}

{
Kokkos::View<int*> workVec("x", TEST_SIZE);
Kokkos::DefaultExecutionSpace exec;

for (long long i = 0 ; i < TEST_SIZE; ++i)
workVec(i) = uni(rng);
long long length;

char *a = argv[1];
length = atoll(a);

std::cout << "running experiment with size of " + std::to_string(length) << "\n";

getExecutionTime("kokkos::parallel_for sort", [&workVec, &exec]() mutable {
Kokkos::sort(exec, workVec);
});
}
runTaskSize(length);

Kokkos::finalize();
std::cout << "\n";
}
Kokkos::finalize();
std::cout << "\n";

}
// {
// Kokkos::View<double*> workVec ("x", length);

// for (long long i = 0 ; i < length; ++i)
// workVec(i) = uni(rng);

// getExecutionTime("kokkos::parallel_for transform", [&workVec]() mutable { // (6)
// Kokkos::parallel_for("kokkos::parallel_for transform", length, KOKKOS_LAMBDA (const int& i) {
// workVec(i) = std::tan(workVec(i) );
// });
// });
// }
10 changes: 7 additions & 3 deletions nvc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# nvc++ -w -fast -Mnouniform -Mfprelaxed -stdpar=gpu -std=c++11 -DUSE_MPI=0 stdPar.cpp -o stdPar
set(CMAKE_CXX_COMPILER "nvc++")
set(CMAKE_C_COMPILER "nvc")
set(CMAKE_CXX_FLAGS "-w -fast -Mnouniform -Mfprelaxed -stdpar=gpu -std=c++11 -DUSE_MPI=0")

add_executable(nvcPar nvcPar.cpp)
target_include_directories(nvcPar PRIVATE "${CMAKE_CURRENT_LIST_DIR}/commons")
# set(CMAKE_CXX_FLAGS "-w -fast -Mnouniform -Mfprelaxed -stdpar=multicore -std=c++11 -DUSE_MPI=0")
# add_executable(nvcParMulticore nvcPar.cpp)
# target_include_directories(nvcParMulticore PRIVATE "${CMAKE_CURRENT_LIST_DIR}/commons")

set(CMAKE_CXX_FLAGS "-w -fast -Mnouniform -Mfprelaxed -stdpar=gpu -std=c++11 -DUSE_MPI=0")
add_executable(nvcParGpu nvcPar.cpp)
target_include_directories(nvcParGpu PRIVATE "${CMAKE_CURRENT_LIST_DIR}/commons")
Binary file added nvc/nvcPar
Binary file not shown.
18 changes: 15 additions & 3 deletions nvc/nvcPar.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

#include <commons.hpp>

int main(){
void runTaskSize(const long long length) {

std::vector<double> workVec(TEST_SIZE);
for (size_t i =0; i < TEST_SIZE; ++i) {
std::vector<double> workVec(length);
for (size_t i =0; i < length; ++i) {
workVec[i] = uni(rng);
}

Expand Down Expand Up @@ -43,4 +43,16 @@ int main(){
});

std::cout << '\n';
}


int main(int argc, char** argv){
long long length;

char *a = argv[1];
length = atoll(a);

std::cout << "running experiment with size of " + std::to_string(length) << "\n";

runTaskSize(length);
}
Binary file added nvc/nvcPar_cpu
Binary file not shown.
Binary file added nvc/nvcPar_gpu
Binary file not shown.
84 changes: 64 additions & 20 deletions scripts.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,65 @@
module purge
source /opt/cray/pe/cpe/22.11/restore_system_defaults.sh

module load gcc/11.2.0

mkdir -p build && cd build
make clean
cmake -DCMAKE_BUILD_TYPE=Release ..
make

cd /global/homes/w/wwei/src/parSTL/build
./hpx/hpxPar --hpx:threads=64
OMP_NUM_THREADS=64 OMP_PLACES=threads OMP_PROC_BIND=close ./kokkos/kokkosPar
./std/stdPar
./gnu/gnuPar

module purge
source /opt/cray/pe/cpe/22.11/restore_system_defaults.sh
module load nvhpc/22.7
./nvc/nvcPar
#!/bin/bash

#SBATCH -A nstaff

#SBATCH -C gpu
#SBATCH -t 30:00
#SBATCH -q regular
#SBATCH -N 1
#SBATCH --ntasks-per-node=1

#SBATCH -o stdpar3.out
#SBATCH -e stdpar3.err

# for SIZE in 100000 1000000 10000000 100000000
for SIZE in 100000000
do
# echo "running stdParTbb_gcc with $SIZE workload"
# ./stdParTbb_gcc $SIZE

# echo "running stdParTbb_clang with $SIZE workload"
# ./stdParTbb_clang $SIZE

# echo "running nvcPar_cpu with $SIZE workload"
# ./nvcPar_cpu $SIZE

# echo "running nvcPar_gpu with $SIZE workload"
# ./nvcPar_gpu $SIZE

for NUM_THREADS in 1 2 4 8 16 32 64 128
# for NUM_THREADS in 128
do
# echo "running hpxPar_gcc with $SIZE workload and $NUM_THREADS"
# ./hpxPar_gcc $SIZE --hpx:threads=$NUM_THREADS

# echo "running hpxPar_clang with $SIZE workload and $NUM_THREADS"
# ./hpxPar_clang $SIZE --hpx:threads=$NUM_THREADS

# echo "running gnuPar_gcc with $SIZE workload and $NUM_THREADS"
# OMP_NUM_THREADS=$NUM_THREADS OMP_PROC_BIND=spread OMP_PLACES=threads ./gnuPar_gcc $SIZE

# echo "running gnuPar_clang with $SIZE workload and $NUM_THREADS"
# OMP_NUM_THREADS=$NUM_THREADS OMP_PROC_BIND=spread OMP_PLACES=threads ./gnuPar_clang $SIZE

# echo "running kokkosPar_openmp_gcc with $SIZE workload and $NUM_THREADS"
# OMP_PROC_BIND=spread OMP_PLACES=threads ./kokkosPar_openmp_gcc $SIZE --kokkos-num-threads=$NUM_THREADS

# echo "running kokkosPar_threads_gcc with $SIZE workload and $NUM_THREADS"
# ./kokkosPar_threads_gcc $SIZE --kokkos-num-threads=$NUM_THREADS

# echo "running kokkosPar_openmp_clang with $SIZE workload and $NUM_THREADS"
# OMP_PROC_BIND=spread OMP_PLACES=threads ./kokkosPar_openmp_clang $SIZE --kokkos-num-threads=$NUM_THREADS

# echo "running kokkosPar_threads_clang with $SIZE workload and $NUM_THREADS"
# ./kokkosPar_threads_clang $SIZE --kokkos-num-threads=$NUM_THREADS

echo "running taskflowPar_gcc with $SIZE workload and $NUM_THREADS"
./taskflowPar_gcc $SIZE $NUM_THREADS

echo "running taskflowPar_clang with $SIZE workload and $NUM_THREADS"
./taskflowPar_clang $SIZE $NUM_THREADS
done

done


8 changes: 0 additions & 8 deletions std/CMakeLists.txt

This file was deleted.

4 changes: 4 additions & 0 deletions stdTbb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
find_package(TBB REQUIRED tbb)
add_executable(stdParTbb stdParTbb.cpp)
target_link_libraries(stdParTbb PUBLIC TBB::tbb)
target_include_directories(stdParTbb PRIVATE "${CMAKE_SOURCE_DIR}/commons")
Loading

0 comments on commit 0a91861

Please sign in to comment.