Added a compilation routine, probably will abstract all this out into

it's own class / function. Added a small kernel that I got from a tutorial
to test the compilers error codes. Added a small notes file with error
codes. Added some error checking for the error codes
This commit is contained in:
2016-08-11 21:39:06 -07:00
parent 49817f94b7
commit d2b79ceec3
3 changed files with 162 additions and 7 deletions

32
kernels/kernel.txt Normal file
View File

@@ -0,0 +1,32 @@
__constant sampler_t sampler =
CLK_NORMALIZED_COORDS_FALSE
| CLK_ADDRESS_CLAMP_TO_EDGE
| CLK_FILTER_NEAREST;
__constant int FILTER_SIZE = 10;
float FilterValue (__constant const float* filterWeights,
const int x, const int y)
{
return filterWeights[(x+FILTER_SIZE) + (y+FILTER_SIZE)*(FILTER_SIZE*2 + 1)];
}
__kernel void Filter (
__read_only image2d_t input,
__constant float* filterWeights,
__write_only image2d_t output)
{
const int2 pos = {get_global_id(0), get_global_id(1)};
float4 sum = (float4)(0.0f);
for(int y = -FILTER_SIZE; y <= FILTER_SIZE; y++) {
for(int x = -FILTER_SIZE; x <= FILTER_SIZE; x++) {
sum += FilterValue(filterWeights, x, y)
* read_imagef(input, sampler, pos + (int2)(x,y));
}
}
write_imagef (output, (int2)(pos.x, pos.y), sum);
}