merge dks-1.0.0-branch (fix conflicts)
This commit is contained in:
@ -83,4 +83,4 @@ TARGET_LINK_LIBRARIES(testFFTSolverMIC dks ${Boost_LIBRARIES} ${CLFFT_LIBRARIES}
|
||||
#IF (NOT CUDA_VERSION VERSION_LESS "7.0")
|
||||
#ADD_EXECUTABLE(testChiSquareRT testChiSquareRT.cpp)
|
||||
#TARGET_LINK_LIBRARIES(testChiSquareRT dks)
|
||||
#ENDIF (NOT CUDA_VERSION VERSION_LESS "7.0")
|
||||
#ENDIF (NOT CUDA_VERSION VERSION_LESS "7.0")
|
||||
|
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