# HG changeset patch # User ikkun # Date 1486637492 -32400 # Node ID 2bc63a22dd215de68555962e0dc854981584144d # Parent 87128b876c63e9e52a5653c8c789a1aa09dcd1f3 add twice diff -r 87128b876c63 -r 2bc63a22dd21 src/test/CMakeLists.txt --- a/src/test/CMakeLists.txt Thu Feb 09 19:02:15 2017 +0900 +++ b/src/test/CMakeLists.txt Thu Feb 09 19:51:32 2017 +0900 @@ -2,13 +2,28 @@ # add_definitions("-Wall -g -O0") -# set(CMAKE_C_COMPILER $ENV{CbC_Clang}/clang) +set(CMAKE_C_COMPILER $ENV{CBC_COMPILER}) +set(CUDA_LINK_FLAGS "-Wl,-search_paths_first -Wl,-headerpad_max_install_names /Developer/NVIDIA/CUDA-8.0/lib/libcudart_static.a -Wl,-rpath,/usr/local/cuda/lib") +SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" ) cmake_minimum_required(VERSION 2.8) find_package(CUDA REQUIRED) -add_custom_command(OUTPUT test.o - DEPENDS test.c - COMMAND cbclang -c test.c +add_custom_command(OUTPUT main.o + DEPENDS main.cu + COMMAND nvcc -O -c main.cu ) -cuda_add_executable(cudaExmple main.cu test.o) + +add_executable(cudaExmple main.o test.c) + +add_custom_command(OUTPUT twice.o + DEPENDS twice.cu + COMMAND nvcc -O -c twice.cu +) + +add_custom_command(OUTPUT multiply.o + DEPENDS multiply.cu + COMMAND nvcc -O -c multiply.cu +) + +add_executable(twiceExmple twice.o multiply.o test.c) diff -r 87128b876c63 -r 2bc63a22dd21 src/test/main.cc --- a/src/test/main.cc Thu Feb 09 19:02:15 2017 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -#include -#include -#include -#include - -extern "C" -{ -//#include -} -#include - -#define LENGTH (10) -#define THREAD (10) - -void -report_error(cudaError_t err, const char* file, int lineNo) { - fprintf(stderr, "[cudaError] %s (error code: %d) at %s line %d\n", cudaGetErrorString(err), err, file, lineNo); -} - -#define CUDA_CALL(func) \ - do { \ - if ((func) != CUDA_SUCCESS) { \ - cudaError_t err = cudaGetLastError(); \ - report_error(err, __FILE__, __LINE__); \ - exit(err); \ - } \ - } while(0) - -double -getTime() { - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec + (double)tv.tv_usec*1e-6; -} - -void -check_data(float* A, float B, float* C) { - for (int i=0; i +#include +#include +#include + +#include + +#include +#include "helper_cuda.h" + +#define LENGTH (10) +#define THREAD (10) + +double +getTime() { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec + (double)tv.tv_usec*1e-6; +} + +void +check_data(float* A, float B, float* C) { + for (int i=0; i