409 |
assert(err == CL_SUCCESS); |
assert(err == CL_SUCCESS); |
410 |
|
|
411 |
/** Memory Allocation for the Matrices **/ |
/** Memory Allocation for the Matrices **/ |
412 |
|
int i; |
413 |
for (int i = 0; i < 4; i++) { |
for ( i = 0; i < 4; i++) { |
414 |
h_mem[i] = clCreateBuffer(context,CL_MEM_READ_ONLY,sizeof(float) * 4,NULL,NULL); |
h_mem[i] = clCreateBuffer(context,CL_MEM_READ_ONLY,sizeof(float) * 4,NULL,NULL); |
415 |
err |= clEnqueueWriteBuffer(queue,h_mem[i],CL_TRUE,0,sizeof(float) * 4, |
err |= clEnqueueWriteBuffer(queue,h_mem[i],CL_TRUE,0,sizeof(float) * 4, |
416 |
(void *)h[i] ,0,NULL,NULL); |
(void *)h[i] ,0,NULL,NULL); |
474 |
err = clEnqueueReadBuffer(queue,out_mem,CL_TRUE,0, sizeof(float) * SIZE,out,0,NULL,NULL); |
err = clEnqueueReadBuffer(queue,out_mem,CL_TRUE,0, sizeof(float) * SIZE,out,0,NULL,NULL); |
475 |
|
|
476 |
// saveResults(out,SIZE * SIZE); |
// saveResults(out,SIZE * SIZE); |
477 |
printMatrix(out,1); |
// printMatrix(out,1); |
478 |
|
|
479 |
clReleaseKernel(kernel); |
clReleaseKernel(kernel); |
480 |
clReleaseProgram(program); |
clReleaseProgram(program); |
482 |
clReleaseContext(context); |
clReleaseContext(context); |
483 |
|
|
484 |
clReleaseMemObject(imageData_mem); |
clReleaseMemObject(imageData_mem); |
485 |
for (int i = 0; i < 4; i++) |
for ( i = 0; i < 4; i++) |
486 |
clReleaseMemObject(h_mem[i]); |
clReleaseMemObject(h_mem[i]); |
487 |
clReleaseMemObject(out_mem); |
clReleaseMemObject(out_mem); |
488 |
clReleaseMemObject(positions_mem); |
clReleaseMemObject(positions_mem); |
493 |
{ |
{ |
494 |
//Declaring and initializing input variables |
//Declaring and initializing input variables |
495 |
Nrrd * nin; |
Nrrd * nin; |
496 |
char * probeValuesFile = "../../data/plane-probe-pos-x.txt"; |
char * probeValuesFile = "../../data/plane-probe-pos-z.txt"; |
497 |
char * dataFile = "../../data/plane-x9.nrrd"; |
char * dataFile = "../../data/plane-z9.nrrd"; |
498 |
float h0[] = {1.33333, 2, 1, 0.166667}; /* -2..-1 */ |
float h0[] = {1.33333, 2, 1, 0.166667}; /* -2..-1 */ |
499 |
float h1[] = {0.666667, 0, -1, -0.5}; /* -1..0 */ |
float h1[] = {0.666667, 0, -1, -0.5}; /* -1..0 */ |
500 |
float h2[] = {0.666667, 0, -1, 0.5}; /* 0..1 */ |
float h2[] = {0.666667, 0, -1, 0.5}; /* 0..1 */ |