summaryrefslogtreecommitdiff
path: root/field_tests/kernel.c
diff options
context:
space:
mode:
authorBrett Weiland <brett_weiland@gmail.com>2024-06-11 14:50:14 -0500
committerBrett Weiland <brett_weiland@gmail.com>2024-06-11 14:50:14 -0500
commitcb69732f68c0bd46c1574de16ce1aee6f38e439b (patch)
treedef1daaec81a0d4cd7b3d44b2c26b9535e07579c /field_tests/kernel.c
restartingHEADmaster
Diffstat (limited to 'field_tests/kernel.c')
-rw-r--r--field_tests/kernel.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/field_tests/kernel.c b/field_tests/kernel.c
new file mode 100644
index 0000000..08b9137
--- /dev/null
+++ b/field_tests/kernel.c
@@ -0,0 +1,26 @@
+__kernel void basic_test() {
+ printf("this cores ID: (%lu, %lu)\n", get_global_id(0), get_global_id(1));
+}
+
+__kernel void render_frame(__global unsigned int *frame_output,
+ double x_step, double y_step,
+ double x_start, double y_start,
+ unsigned int iterations, unsigned int escape, double ratio) {
+ unsigned int result;
+ double on_x = (get_global_id(0) * x_step) + x_start;
+ double on_y = (get_global_id(1) * y_step) + y_start;
+ double next_x;
+ unsigned int iter;
+
+ orig_x = on_x;
+ orig_y = on_y;
+ for(iter = 0; iter < iterations; iter++) {
+ if(orig_x == 123 && orig_y == 5) printf("%d, %d\n", orig_x,orig_y);
+ next_x = on_x / sin(on_y);
+ on_y = on_y / sin(on_x);
+ on_x = next_x;
+ if((pow(on_x, 2) + pow(on_y, 2)) >= escape) break;
+ }
+
+ frame_output[(get_global_id(1) * get_global_size(1)) + get_global_id(0)] = iter;
+}