6 changed files with 112 additions and 10 deletions
@ -0,0 +1,59 @@ |
|||
#include "LinearTests.h" |
|||
#include "cl.hpp" |
|||
#include "Common.h" |
|||
#include <iostream> |
|||
|
|||
Gauss::Gauss(int _n, int _m, float* _G) { |
|||
n = _n; |
|||
m = _m; |
|||
G = _G; |
|||
} |
|||
|
|||
void Gauss::collect_results(cl::CommandQueue* queue) |
|||
{ |
|||
queue->enqueueReadBuffer(clInputBuffer, true, 0, sizeof(float) * n * m, G); |
|||
} |
|||
|
|||
void Gauss::gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event) |
|||
{ |
|||
cl_int err = CL_SUCCESS; |
|||
|
|||
cl::Kernel kernel = cl::Kernel(*program, "gaussian", &err); |
|||
CheckCLError(err); |
|||
|
|||
clInputBuffer = cl::Buffer(*context, CL_MEM_READ_ONLY, sizeof(float) * n * m, NULL, &err); |
|||
CheckCLError(err); |
|||
queue->enqueueWriteBuffer(clInputBuffer, true, 0, sizeof(float) * n * m, G); |
|||
|
|||
kernel.setArg(0, n); |
|||
kernel.setArg(1, m); |
|||
kernel.setArg(2, clInputBuffer); |
|||
|
|||
queue->enqueueNDRangeKernel(kernel, |
|||
cl::NullRange, |
|||
cl::NDRange(n, 1), |
|||
cl::NDRange(n, 1), |
|||
NULL, |
|||
Event); |
|||
} |
|||
|
|||
void Gauss::cpu_compute() |
|||
{ |
|||
} |
|||
|
|||
bool Gauss::validate_results() |
|||
{ |
|||
for (int i = 0; i < m; ++i) { |
|||
for (int j = 0; j < n; ++j) { |
|||
std::cout << G[j + i * n]; |
|||
if (j < n - 1) std::cout << ", "; |
|||
} |
|||
std::cout << std::endl; |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
std::string Gauss::description() |
|||
{ |
|||
return std::string(); |
|||
} |
Loading…
Reference in new issue