Skip to content

Commit 5d644bc

Browse files
author
Balint Joo
committed
Modified files so example builds with CodePlay's ComputeCPP compiler
This primarily involved: i) turning off references to OpenMP (compiler had issues finding omp.h) including rewriting the timers with the std::chrono interface ii) ComputeCPP didn't like template function specialization within a class scope, and so the VN::template permute<dir> functions had to be changed to permuteX, permuteY, permuteZ, permuteT respectively. A downside is that in mat_mult_perm we now have to have a 4 clause if statement to select this based on the perm_dir template. iii) Added .cmake files from ComputeCPP-SDK (and associated LICENSE) iv) Revamped CMakeLists to allow specification of CodePlay build using -DMG_USE_COMPUTE_CPP=ON -DComputeCpp_DIR=<...> options to CMake
1 parent 49efdaa commit 5d644bc

17 files changed

+860
-206
lines changed

CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ option(MG_FORTRANLIKE_COMPLEX "Fortran like complex ordering (r,i,r,i,...r,i) fo
2020
option(MG_DEBUG_INCLUDES "Print info about complex/vnode file inclusion. Default is OFF" OFF)
2121
option(MG_USE_LAYOUT_LEFT "Use left fastest indexing. Default is ON" ON)
2222
option(MG_USE_NEIGHBOR_TABLE "Use memory based table for neighbor indexing (as opposed to computing on the fly). Default is OFF" OFF)
23+
option(MG_USE_COMPUTE_CPP "Use ComputeCPP" OFF)
24+
25+
if ( MG_USE_COMPUTE_CPP )
26+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
27+
include(${PROJECT_SOURCE_DIR}/cmake/FindComputeCpp.cmake)
28+
find_package(ComputeCpp)
29+
endif()
30+
2331
# Default Loglevel
2432
if ( NOT MG_DEFAULT_LOGLEVEL )
2533
if ( CMAKE_BUILD_TYPE )

LICENSE

+32
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,35 @@ THIS SOFTWARE IS PROVIDED BY JEFFERSON SCIENCE ASSOCIATES LLC "AS IS" AND ANY EX
1919
Other parts are copyrighted by their respective contributors, but are
2020
distributed under the same license.
2121

22+
This software includes in the cmake/ directory Cmake modules which were published by Codeplay Software
23+
which enable compilation of SyCL Code using the CMake build system. These files are published under
24+
the computecpp-sdk samples, available at [ https://github.com/codeplaysoftware/computecpp-sdk ]( https://github.com/codeplaysoftware/computecpp-sdk ), and are licensed by Codeplay under the Apache license. The License is reproduced in the LICENSES/LICENSE_compputeCPP file in this package, and below:
25+
26+
 Copyright 2016 Codeplay Software Ltd.
27+
28+
Licensed under the Apache License, Version 2.0 (the "License");
29+
you may not use these files except in compliance with the License.
30+
You may obtain a copy of the License at
31+
32+
http://www.apache.org/licenses/LICENSE-2.0
33+
34+
For your convenience, a copy of the License has been included in this
35+
repository.
36+
37+
Unless required by applicable law or agreed to in writing, software
38+
distributed under the License is distributed on an "AS IS" BASIS,
39+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40+
See the License for the specific language governing permissions and
41+
limitations under the License.
42+
43+
The files samples/gaussian_blur/stb_image.h and stb_image_write.h are
44+
in the Public Domain. Originally authored by Sean Barrett.
45+
https://github.com/nothings/stb
46+
47+
The file samples/smart_pointer/stack_allocator.hpp is (c) Charles Salvia
48+
and is available under the MIT License.
49+
https://github.com/charles-salvia/charles
50+
51+
52+
53+

LICENSES/LICENSE_computeCPP

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2016 Codeplay Software Ltd.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use these files except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
For your convenience, a copy of the License has been included in this
10+
repository.
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
The files samples/gaussian_blur/stb_image.h and stb_image_write.h are
19+
in the Public Domain. Originally authored by Sean Barrett.
20+
https://github.com/nothings/stb
21+
22+
The file samples/smart_pointer/stack_allocator.hpp is (c) Charles Salvia
23+
and is available under the MIT License.
24+
https://github.com/charles-salvia/charles
25+

cmake/ComputeCppCompilerChecks.cmake

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
cmake_minimum_required(VERSION 3.4.3)
2+
3+
if(CMAKE_COMPILER_IS_GNUCXX)
4+
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
5+
message(FATAL_ERROR "host compiler - gcc version must be > 4.8")
6+
endif()
7+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
8+
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.6)
9+
message(FATAL_ERROR "host compiler - clang version must be > 3.6")
10+
endif()
11+
endif()
12+
13+
if(MSVC)
14+
set(ComputeCpp_STL_CHECK_SRC __STL_check)
15+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp
16+
"#include <ios>\n"
17+
"int main() { return 0; }\n")
18+
execute_process(
19+
COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE}
20+
${COMPUTECPP_DEVICE_COMPILER_FLAGS}
21+
-isystem ${ComputeCpp_INCLUDE_DIRS}
22+
-o ${ComputeCpp_STL_CHECK_SRC}.sycl
23+
-c ${ComputeCpp_STL_CHECK_SRC}.cpp
24+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
25+
RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT
26+
ERROR_QUIET
27+
OUTPUT_QUIET)
28+
if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0)
29+
# Try disabling compiler version checks
30+
execute_process(
31+
COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE}
32+
${COMPUTECPP_DEVICE_COMPILER_FLAGS}
33+
-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH
34+
-isystem ${ComputeCpp_INCLUDE_DIRS}
35+
-o ${ComputeCpp_STL_CHECK_SRC}.cpp.sycl
36+
-c ${ComputeCpp_STL_CHECK_SRC}.cpp
37+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
38+
RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT
39+
ERROR_QUIET
40+
OUTPUT_QUIET)
41+
if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0)
42+
message(STATUS "Device compiler cannot consume hosted STL headers. Using any parts of the STL will likely result in device compiler errors.")
43+
else()
44+
message(STATUS "Device compiler does not meet certain STL version requirements. Disabling version checks and hoping for the best.")
45+
list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH)
46+
endif()
47+
endif()
48+
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp
49+
${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp.sycl)
50+
endif(MSVC)

cmake/ComputeCppIRMap.cmake

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cmake_minimum_required(VERSION 3.4.3)
2+
3+
# These should match the types of IR output by compute++
4+
set(IR_MAP_spir bc)
5+
set(IR_MAP_spir64 bc)
6+
set(IR_MAP_spir32 bc)
7+
set(IR_MAP_spirv spv)
8+
set(IR_MAP_spirv64 spv)
9+
set(IR_MAP_spirv32 spv)
10+
set(IR_MAP_aorta-x86_64 o)
11+
set(IR_MAP_aorta-aarch64 o)
12+
set(IR_MAP_aorta-rcar-cve o)
13+
set(IR_MAP_custom-spir64 bc)
14+
set(IR_MAP_custom-spir32 bc)
15+
set(IR_MAP_custom-spirv64 spv)
16+
set(IR_MAP_custom-spirv32 spv)
17+
set(IR_MAP_ptx64 s)
18+
set(IR_MAP_amdgcn s)

0 commit comments

Comments
 (0)