Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Minor updates to SYCL Parallel STL #87

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 18 additions & 10 deletions CMakeLists.txt
Expand Up @@ -7,34 +7,42 @@ option(PARALLEL_STL_BENCHMARKS "Build the internal benchmarks" OFF)
option(USE_COMPUTECPP "Use ComputeCPP" ON)

message(STATUS " Path to CMAKE source directory: ${CMAKE_SOURCE_DIR} ")
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
find_package(Threads REQUIRED)

set(CMAKE_CXX_STANDARD 14)

if (USE_COMPUTECPP)
message(STATUS " Using ComputeCpp CMake")

message(STATUS " Path to ComputeCpp implementation: ${COMPUTECPP_PACKAGE_ROOT_DIR} ")

set(CMAKE_CXX_STANDARD 11)

include(FindOpenCL)
include(FindComputeCpp)

add_definitions(-DSYCL_PSTL_USE_OLD_ALGO)
set(COMPUTECPP_DEVICE_COMPILER_FLAGS "${COMPUTECPP_DEVICE_COMPILER_FLAGS} -DSYCL_PSTL_USE_OLD_ALGO")

include_directories("${COMPUTECPP_INCLUDE_DIRECTORY}")


set(SYCL_LIBRARY ${COMPUTECPP_RUNTIME_LIBRARY})
set(SYCL_INCLUDE_DIRS ${ComputeCpp_INCLUDE_DIRS})
else()
message(STATUS " Using triSYCL CMake")
include(FindTriSYCL)
set(SYCL_INCLUDE_DIRS ${TRISYCL_INCLUDE_DIR})
set(SYCL_LIBRARY) # Not needed for TriSYCL
endif()


# PSTL specific
include_directories("include")

# Function to build a file
function(build_file file)
get_filename_component(SOURCE_NAME ${file} NAME_WE)
message(STATUS " Adding ${SOURCE_NAME} ")

add_executable(${SOURCE_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${file} )

add_sycl_to_target(TARGET ${SOURCE_NAME} SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/${file})
endfunction()

add_subdirectory (src)
add_subdirectory (examples)
add_subdirectory (tests)
Expand Down
39 changes: 21 additions & 18 deletions benchmarks/CMakeLists.txt
@@ -1,19 +1,22 @@
file(GLOB EXAMPLE_FILES ./*.cpp)

foreach(file ${EXAMPLE_FILES})

get_filename_component(SOURCE_NAME ${file} NAME_WE)
message(STATUS " Adding ${SOURCE_NAME} ")

include_directories(${COMPUTECPP_INCLUDE_DIRECTORY})

add_executable(${SOURCE_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_NAME}.cpp )
target_compile_options(${SOURCE_NAME} PUBLIC ${HOST_COMPILER_OPTIONS})

target_link_libraries(${SOURCE_NAME} PUBLIC ${CMAKE_THREAD_LIBS_INIT})

add_sycl_to_target(${SOURCE_NAME} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_NAME}.cpp)


set(BENCHMARK_FILES
"basic.cpp"
"montecarloPI.cpp"
"nbody.cpp"
"std_foreach_saxpy.cpp"
"std_sort.cpp"
"std_transform_saxpy.cpp"
"sycl_exclusive_scan.cpp"
"sycl_foreach_saxpy.cpp"
"sycl_inclusive_scan.cpp"
"sycl_reduce.cpp"
"sycl_sort.cpp"
"sycl_transform_het_saxpy.cpp"
"sycl_transform_reduce_saxpy.cpp"
"sycl_transform_saxpy.cpp"
"word_count.cpp"
)


foreach(file ${BENCHMARK_FILES})
build_file(${file})
endforeach()
63 changes: 0 additions & 63 deletions benchmarks/amd_cpu_selector.hpp

This file was deleted.

3 changes: 1 addition & 2 deletions benchmarks/sycl_transform_het_saxpy.cpp
Expand Up @@ -35,7 +35,6 @@

#include <experimental/algorithm>
#include <sycl/heterogeneous_execution_policy.hpp>
#include "amd_cpu_selector.hpp"

#include "benchmark.h"

Expand All @@ -56,7 +55,7 @@ benchmark<>::time_units_t benchmark_transform_heterogeneous(
res.push_back(i);
}
cl::sycl::queue q;
amd_cpu_selector cpu_sel;
cl::sycl::cpu_selector cpu_sel;
cl::sycl::queue q2(cpu_sel);
sycl::sycl_heterogeneous_execution_policy<class TransformAlgorithm1> snp(
q, q2, ratio);
Expand Down
21 changes: 2 additions & 19 deletions build.sh
Expand Up @@ -49,31 +49,15 @@ then
CMAKE_ARGS="$CMAKE_ARGS -DUSE_COMPUTECPP=OFF $@"
else
echo "build.sh entering mode: ComputeCpp"
CMAKE_ARGS="$CMAKE_ARGS -DCOMPUTECPP_PACKAGE_ROOT_DIR=$(readlink -f $1)"
CMAKE_ARGS="$CMAKE_ARGS -DComputeCpp_DIR=$(readlink -f $1)"
shift
fi

NPROC=$(nproc)

function install_gmock {(
REPO="https://github.com/google/googletest.git"
mkdir -p external
cd external
if [ -d googletest ]
then
cd googletest
$NO_DOWNLOAD git pull
else
$NO_DOWNLOAD git clone $REPO
cd googletest
fi
cd googlemock/make
make -j$NPROC
)}

function configure {
mkdir -p build && pushd build
cmake .. $CMAKE_ARGS -DPARALLEL_STL_BENCHMARKS=ON
cmake .. $CMAKE_ARGS -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPARALLEL_STL_BENCHMARKS=ON
popd
}

Expand All @@ -89,7 +73,6 @@ function tst {
}

function main {
install_gmock
configure
mak
tst
Expand Down