merge dks-1.0.0-branch (fix conflicts)
This commit is contained in:
@ -108,14 +108,16 @@ IF ( (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "
|
||||
SET (USE_CUDA ON)
|
||||
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${CUDA_TOOLKIT_ROOT_DIR}/lib64)
|
||||
LINK_DIRECTORIES(${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs)
|
||||
|
||||
MESSAGE (STATUS "cuda include: ${CUDA_INCLUDE_DIRS}")
|
||||
MESSAGE (STATUS "cuda libs: ${CUDA_TOOLKIT_ROOT_DIR}/lib64")
|
||||
MESSAGE (STATUS "cuda version: ${CUDA_VERSION}")
|
||||
SET(CUDA_PROPAGATE_HOST_FLAGS OFF)
|
||||
|
||||
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcudart -lcufft -lcublas -lnvToolsExt -DDKS_CUDA")
|
||||
SET (CUDA_NVCC_FLAGS "-arch=sm_35 -DDEBUG -lcufft -lcublas -lcudart -fmad=false")
|
||||
|
||||
SET (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -DDEBUG -std=c++11 -D__wsu")
|
||||
SET (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} ${OPENCL_KERNELS}")
|
||||
|
||||
#if cuda version >= 7.0 add runtime commpilation flags
|
||||
@ -140,6 +142,7 @@ IF ( (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "
|
||||
MESSAGE(STATUS "OpenCL version : ${OpenCL_VERSION_STRING}")
|
||||
MESSAGE(STATUS "OpenCL include dir: ${OpenCL_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "OpenCL library dir: ${OpenCL_LIBRARY}")
|
||||
SET(CMAKE_SKIP_RPATH TRUE)
|
||||
INCLUDE_DIRECTORIES(${OpenCL_INCLUDE_DIR})
|
||||
LINK_DIRECTORIES(${OpenCL_LIBRARY})
|
||||
ENDIF (OpenCL_FOUND)
|
||||
|
@ -1,4 +1,5 @@
|
||||
SET(${PROJECT_NAME}_CMAKE_CXX_FLAGS "${${PROJECT_NAME}_CXX_FLAGS}")
|
||||
SET(${PROJECT_NAME}_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
SET(${PROJECT_NAME}_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
|
||||
SET(${PROJECT_NAME}_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
SET(${PROJECT_NAME}_LIBRARY "dks")
|
||||
SET(CMAKE_SKIP_RPATH ${CMAKE_SKIP_RPATH})
|
81
test/testRandom.cpp
Normal file
81
test/testRandom.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "DKSBase.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
int size = 10;
|
||||
bool apiSet = false;
|
||||
char *api_name = new char[10];
|
||||
char *device_name = new char[10];
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
|
||||
if (argv[i] == string("-cuda")) {
|
||||
strcpy(api_name, "Cuda");
|
||||
strcpy(device_name, "-gpu");
|
||||
apiSet = true;
|
||||
}
|
||||
|
||||
if (argv[i] == string("-opencl")) {
|
||||
strcpy(api_name, "OpenCL");
|
||||
strcpy(device_name, "-gpu");
|
||||
apiSet = true;
|
||||
}
|
||||
|
||||
if (argv[i] == string("-N")) {
|
||||
size = atoi(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!apiSet) {
|
||||
strcpy(api_name, "Cuda");
|
||||
strcpy(device_name, "-gpu");
|
||||
}
|
||||
|
||||
cout << "=========================BEGIN TEST=========================" << endl;
|
||||
cout << "Use api: " << api_name << "\t" << device_name << endl;
|
||||
cout << "Number of randoms: " << size << endl;
|
||||
|
||||
//init dks
|
||||
int ierr;
|
||||
DKSBase base;
|
||||
base.setAPI(api_name, strlen(api_name));
|
||||
base.setDevice(device_name, strlen(api_name));
|
||||
base.initDevice();
|
||||
base.callInitRandoms(size);
|
||||
|
||||
//create host vector to store results
|
||||
double *host_data = new double[size];
|
||||
|
||||
//create device vector
|
||||
void *device_data = base.allocateMemory<double>(size, ierr);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
//fill device vector with random values
|
||||
base.callCreateRandomNumbers(device_data, size);
|
||||
|
||||
//read device vector
|
||||
base.readData<double>(device_data, host_data, size);
|
||||
|
||||
//print host data
|
||||
for (int i = 0; i < size; i++)
|
||||
cout << host_data[i] << " ";
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
//free device vector
|
||||
base.freeMemory<double>(device_data, size);
|
||||
|
||||
//free host data
|
||||
delete[] host_data;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user