[Libclc-dev] [PATCH 2/3] amdgcn-amdhsa: Add get_num_groups implementation

Tom Stellard via Libclc-dev libclc-dev at lists.llvm.org
Wed Sep 14 04:22:56 PDT 2016


---
 amdgcn-amdhsa/lib/OVERRIDES                  |  1 +
 amdgcn-amdhsa/lib/SOURCES                    |  1 +
 amdgcn-amdhsa/lib/workitem/get_num_groups.cl | 12 ++++++++++++
 3 files changed, 14 insertions(+)
 create mode 100644 amdgcn-amdhsa/lib/workitem/get_num_groups.cl

diff --git a/amdgcn-amdhsa/lib/OVERRIDES b/amdgcn-amdhsa/lib/OVERRIDES
index e69de29..c9bd69b 100644
--- a/amdgcn-amdhsa/lib/OVERRIDES
+++ b/amdgcn-amdhsa/lib/OVERRIDES
@@ -0,0 +1 @@
+workitem/get_num_groups.ll
diff --git a/amdgcn-amdhsa/lib/SOURCES b/amdgcn-amdhsa/lib/SOURCES
index 257942c..7b7ea4a 100644
--- a/amdgcn-amdhsa/lib/SOURCES
+++ b/amdgcn-amdhsa/lib/SOURCES
@@ -1,2 +1,3 @@
 workitem/get_global_size.ll
 workitem/get_local_size.ll
+workitem/get_num_groups.cl
diff --git a/amdgcn-amdhsa/lib/workitem/get_num_groups.cl b/amdgcn-amdhsa/lib/workitem/get_num_groups.cl
new file mode 100644
index 0000000..946b526
--- /dev/null
+++ b/amdgcn-amdhsa/lib/workitem/get_num_groups.cl
@@ -0,0 +1,12 @@
+
+#include <clc/clc.h>
+
+_CLC_DEF size_t get_num_groups(uint dim) {
+  size_t global_size = get_global_size(dim);
+  size_t local_size = get_local_size(dim);
+  size_t num_groups = global_size / local_size;
+  if (global_size % local_size != 0) {
+    num_groups++;
+  }
+  return num_groups;
+}
-- 
2.7.4



More information about the Libclc-dev mailing list