[Libclc-dev] [PATCH] r600: Initial support

tstellar at gmail.com tstellar at gmail.com
Mon Mar 12 13:00:10 PDT 2012


From: Tom Stellard <thomas.stellard at amd.com>

This includes a get_global_id() implementation and function stubs for
the other workitem and synchronization functions.
---

Thanks for the tips, Peter.  I've left all the workitem functions, besides
get_global_id(), in the header files for now, just because I haven't
implemented enough in the backend for them to work.  I'll eventually
move them all to the lib directory, just like I did with get_global_id().

 configure.py                                |    2 +-
 r600/include/clc/synchronization/barrier.h  |    2 ++
 r600/include/clc/workitem/get_global_id.h   |    1 +
 r600/include/clc/workitem/get_global_size.h |    3 +++
 r600/include/clc/workitem/get_group_id.h    |    3 +++
 r600/include/clc/workitem/get_local_id.h    |    3 +++
 r600/include/clc/workitem/get_local_size.h  |    3 +++
 r600/include/clc/workitem/get_num_groups.h  |    3 +++
 r600/lib/SOURCES                            |    1 +
 r600/lib/workitem/get_global_id.cl          |   10 ++++++++++
 10 files changed, 30 insertions(+), 1 deletions(-)
 create mode 100644 r600/include/clc/synchronization/barrier.h
 create mode 100644 r600/include/clc/workitem/get_global_id.h
 create mode 100644 r600/include/clc/workitem/get_global_size.h
 create mode 100644 r600/include/clc/workitem/get_group_id.h
 create mode 100644 r600/include/clc/workitem/get_local_id.h
 create mode 100644 r600/include/clc/workitem/get_local_size.h
 create mode 100644 r600/include/clc/workitem/get_num_groups.h
 create mode 100644 r600/lib/SOURCES
 create mode 100644 r600/lib/workitem/get_global_id.cl

diff --git a/configure.py b/configure.py
index 310122b..5e86b41 100755
--- a/configure.py
+++ b/configure.py
@@ -40,7 +40,7 @@ llvm_clang = os.path.join(llvm_bindir, 'clang')
 llvm_link = os.path.join(llvm_bindir, 'llvm-link')
 llvm_opt = os.path.join(llvm_bindir, 'opt')
 
-default_targets = ['ptx32--nvidiacl', 'ptx64--nvidiacl']
+default_targets = ['ptx32--nvidiacl', 'ptx64--nvidiacl', 'r600--']
 
 targets = args
 if not targets:
diff --git a/r600/include/clc/synchronization/barrier.h b/r600/include/clc/synchronization/barrier.h
new file mode 100644
index 0000000..7f150d4
--- /dev/null
+++ b/r600/include/clc/synchronization/barrier.h
@@ -0,0 +1,2 @@
+_CLC_INLINE void barrier(cl_mem_fence_flags flags) {
+}
diff --git a/r600/include/clc/workitem/get_global_id.h b/r600/include/clc/workitem/get_global_id.h
new file mode 100644
index 0000000..b61450f
--- /dev/null
+++ b/r600/include/clc/workitem/get_global_id.h
@@ -0,0 +1 @@
+size_t get_global_id(uint dim);
diff --git a/r600/include/clc/workitem/get_global_size.h b/r600/include/clc/workitem/get_global_size.h
new file mode 100644
index 0000000..afd9ae1
--- /dev/null
+++ b/r600/include/clc/workitem/get_global_size.h
@@ -0,0 +1,3 @@
+_CLC_INLINE size_t get_global_size(uint dim) {
+  return 0;
+}
diff --git a/r600/include/clc/workitem/get_group_id.h b/r600/include/clc/workitem/get_group_id.h
new file mode 100644
index 0000000..6862dba
--- /dev/null
+++ b/r600/include/clc/workitem/get_group_id.h
@@ -0,0 +1,3 @@
+_CLC_INLINE size_t get_group_id(uint dim) {
+  return 0;
+}
diff --git a/r600/include/clc/workitem/get_local_id.h b/r600/include/clc/workitem/get_local_id.h
new file mode 100644
index 0000000..22749cd
--- /dev/null
+++ b/r600/include/clc/workitem/get_local_id.h
@@ -0,0 +1,3 @@
+_CLC_INLINE size_t get_local_id(uint dim) {
+  return 0;
+}
diff --git a/r600/include/clc/workitem/get_local_size.h b/r600/include/clc/workitem/get_local_size.h
new file mode 100644
index 0000000..51d9762
--- /dev/null
+++ b/r600/include/clc/workitem/get_local_size.h
@@ -0,0 +1,3 @@
+_CLC_INLINE size_t get_local_size(uint dim) {
+  return 0;
+}
diff --git a/r600/include/clc/workitem/get_num_groups.h b/r600/include/clc/workitem/get_num_groups.h
new file mode 100644
index 0000000..fe1f343
--- /dev/null
+++ b/r600/include/clc/workitem/get_num_groups.h
@@ -0,0 +1,3 @@
+_CLC_INLINE size_t get_num_groups(uint dim) {
+  return 0;
+}
diff --git a/r600/lib/SOURCES b/r600/lib/SOURCES
new file mode 100644
index 0000000..0844030
--- /dev/null
+++ b/r600/lib/SOURCES
@@ -0,0 +1 @@
+workitem/get_global_id.cl
diff --git a/r600/lib/workitem/get_global_id.cl b/r600/lib/workitem/get_global_id.cl
new file mode 100644
index 0000000..9b0bd94
--- /dev/null
+++ b/r600/lib/workitem/get_global_id.cl
@@ -0,0 +1,10 @@
+#include <clc/clc.h>
+
+_CLC_DEF size_t get_global_id(uint dim) {
+  switch (dim) {
+  case 0:  return __builtin_r600_read_tgid_x()*__builtin_r600_read_ngroups_x()+__builtin_r600_read_tidig_x();
+  case 1:  return __builtin_r600_read_tgid_y()*__builtin_r600_read_ngroups_y()+__builtin_r600_read_tidig_y();
+  case 2:  return __builtin_r600_read_tgid_z()*__builtin_r600_read_ngroups_z()+__builtin_r600_read_tidig_z();
+  default: return 0;
+  }
+}
-- 
1.7.7.6





More information about the Libclc-dev mailing list