Add CMakeLists.txt file with CUDA and OCL builds

This commit is contained in:
Tom Deakin 2016-04-28 16:58:32 +01:00
parent 088778977b
commit b9e70e11ab
2 changed files with 28 additions and 1 deletions

19
CMakeLists.txt Normal file
View File

@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 2.8)
project(gpu-stream)
set(CMAKE_SOURCE_DIR src/)
list(APPEND CMAKE_CXX_FLAGS --std=c++11)
find_package(CUDA REQUIRED)
cuda_add_executable(cuda.exe src/main.cpp src/CUDAStream.cu)
target_compile_definitions(cuda.exe PUBLIC CUDA)
find_package(OpenCL)
add_executable(ocl.exe src/main.cpp src/OCLStream.cpp)
target_compile_definitions(ocl.exe PUBLIC OCL)
target_link_libraries(ocl.exe ${OpenCL_LIBRARY})

View File

@ -11,7 +11,11 @@
#include "common.h"
#include "Stream.h"
#if defined(CUDA)
#include "CUDAStream.h"
#elif defined(OCL)
#include "OCLStream.h"
#endif
const unsigned int ARRAY_SIZE = 52428800;
@ -45,12 +49,16 @@ void run()
Stream<T> *stream;
#if defined(CUDA)
// Use the CUDA implementation
//stream = new CUDAStream<T>(ARRAY_SIZE);
stream = new CUDAStream<T>(ARRAY_SIZE);
#elif defined(OCL)
// Use the OpenCL implementation
stream = new OCLStream<T>(ARRAY_SIZE);
#endif
stream->write_arrays(a, b, c);
// List of times