summaryrefslogtreecommitdiffstats
path: root/kernel.cl
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2016-06-19 05:11:03 +0200
committerSuren A. Chilingaryan <csa@suren.me>2016-06-19 05:11:03 +0200
commit151541b83d540c3476965368f819e48a7b289cad (patch)
treee06abd228903a00c4dc4d105c4e9309c96da38d3 /kernel.cl
downloaddgmatest-151541b83d540c3476965368f819e48a7b289cad.tar.gz
dgmatest-151541b83d540c3476965368f819e48a7b289cad.tar.bz2
dgmatest-151541b83d540c3476965368f819e48a7b289cad.tar.xz
dgmatest-151541b83d540c3476965368f819e48a7b289cad.zip
Initial
Diffstat (limited to 'kernel.cl')
-rw-r--r--kernel.cl19
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel.cl b/kernel.cl
new file mode 100644
index 0000000..26a0009
--- /dev/null
+++ b/kernel.cl
@@ -0,0 +1,19 @@
+#define REG_PERF_COUNTER 0x20
+#define REG_DESCRIPTOR_ADDRESS 0x50
+
+#define RD32(addr) ((__global volatile uint*)bar)[addr / 4];
+#define WR32(addr, value) ((__global volatile uint*)bar)[addr / 4] = value;
+#define WR64(addr, value) ((__global volatile ulong*)bar)[addr / 8] = value;
+
+__kernel void process(uint iter, __global uint *input, __global uint *output, __global volatile uint *bar, ulong bus_addr)
+{
+ WR32 (REG_PERF_COUNTER, 1);
+}
+
+
+__kernel void measure(uint iter, __global uint *input, __global uint *output, __global volatile uint *bar, ulong bus_addr)
+{
+ output[0] = iter;
+ output[iter + 1] = RD32(REG_PERF_COUNTER);
+ WR64 (REG_DESCRIPTOR_ADDRESS, bus_addr);
+}