[Libclc-dev] [PATCH 2/5] amdgcn: Convert get_global_size to clc
Jan Vesely via Libclc-dev
libclc-dev at lists.llvm.org
Sun Oct 28 23:43:02 PDT 2018
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
amdgcn/lib/OVERRIDES_3.9 | 1 -
amdgcn/lib/OVERRIDES_4.0 | 1 -
amdgcn/lib/OVERRIDES_5.0 | 1 -
amdgcn/lib/OVERRIDES_6.0 | 1 -
amdgcn/lib/SOURCES | 2 +-
amdgcn/lib/SOURCES_3.9 | 1 -
amdgcn/lib/SOURCES_4.0 | 1 -
amdgcn/lib/SOURCES_5.0 | 1 -
amdgcn/lib/SOURCES_6.0 | 1 -
amdgcn/lib/workitem/get_global_size.39.ll | 20 --------------------
amdgcn/lib/workitem/get_global_size.40.ll | 23 -----------------------
amdgcn/lib/workitem/get_global_size.cl | 15 +++++++++++++++
amdgcn/lib/workitem/get_global_size.ll | 23 -----------------------
13 files changed, 16 insertions(+), 75 deletions(-)
delete mode 100644 amdgcn/lib/workitem/get_global_size.39.ll
delete mode 100644 amdgcn/lib/workitem/get_global_size.40.ll
create mode 100644 amdgcn/lib/workitem/get_global_size.cl
delete mode 100644 amdgcn/lib/workitem/get_global_size.ll
diff --git a/amdgcn/lib/OVERRIDES_3.9 b/amdgcn/lib/OVERRIDES_3.9
index ed6c06d..4811cf0 100644
--- a/amdgcn/lib/OVERRIDES_3.9
+++ b/amdgcn/lib/OVERRIDES_3.9
@@ -1,3 +1,2 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
-workitem/get_global_size.ll
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/OVERRIDES_4.0 b/amdgcn/lib/OVERRIDES_4.0
index ed6c06d..4811cf0 100644
--- a/amdgcn/lib/OVERRIDES_4.0
+++ b/amdgcn/lib/OVERRIDES_4.0
@@ -1,3 +1,2 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
-workitem/get_global_size.ll
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/OVERRIDES_5.0 b/amdgcn/lib/OVERRIDES_5.0
index ed6c06d..4811cf0 100644
--- a/amdgcn/lib/OVERRIDES_5.0
+++ b/amdgcn/lib/OVERRIDES_5.0
@@ -1,3 +1,2 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
-workitem/get_global_size.ll
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/OVERRIDES_6.0 b/amdgcn/lib/OVERRIDES_6.0
index ed6c06d..4811cf0 100644
--- a/amdgcn/lib/OVERRIDES_6.0
+++ b/amdgcn/lib/OVERRIDES_6.0
@@ -1,3 +1,2 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
-workitem/get_global_size.ll
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/SOURCES b/amdgcn/lib/SOURCES
index 8e9fdde..666ae10 100644
--- a/amdgcn/lib/SOURCES
+++ b/amdgcn/lib/SOURCES
@@ -10,7 +10,7 @@ mem_fence/fence.cl
synchronization/barrier.cl
workitem/get_global_offset.cl
workitem/get_group_id.cl
-workitem/get_global_size.ll
+workitem/get_global_size.cl
workitem/get_local_id.cl
workitem/get_local_size.cl
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/SOURCES_3.9 b/amdgcn/lib/SOURCES_3.9
index 8b2a255..f4b800f 100644
--- a/amdgcn/lib/SOURCES_3.9
+++ b/amdgcn/lib/SOURCES_3.9
@@ -1,4 +1,3 @@
cl_khr_int64_extended_atomics/minmax_helpers.39.ll
mem_fence/waitcnt.ll
-workitem/get_global_size.39.ll
workitem/get_num_groups.39.ll
diff --git a/amdgcn/lib/SOURCES_4.0 b/amdgcn/lib/SOURCES_4.0
index 5342d54..34f98fe 100644
--- a/amdgcn/lib/SOURCES_4.0
+++ b/amdgcn/lib/SOURCES_4.0
@@ -1,4 +1,3 @@
cl_khr_int64_extended_atomics/minmax_helpers.39.ll
mem_fence/waitcnt.ll
-workitem/get_global_size.40.ll
workitem/get_num_groups.40.ll
diff --git a/amdgcn/lib/SOURCES_5.0 b/amdgcn/lib/SOURCES_5.0
index 0977b32..ed28126 100644
--- a/amdgcn/lib/SOURCES_5.0
+++ b/amdgcn/lib/SOURCES_5.0
@@ -1,3 +1,2 @@
cl_khr_int64_extended_atomics/minmax_helpers.39.ll
-workitem/get_global_size.40.ll
workitem/get_num_groups.40.ll
diff --git a/amdgcn/lib/SOURCES_6.0 b/amdgcn/lib/SOURCES_6.0
index 0977b32..ed28126 100644
--- a/amdgcn/lib/SOURCES_6.0
+++ b/amdgcn/lib/SOURCES_6.0
@@ -1,3 +1,2 @@
cl_khr_int64_extended_atomics/minmax_helpers.39.ll
-workitem/get_global_size.40.ll
workitem/get_num_groups.40.ll
diff --git a/amdgcn/lib/workitem/get_global_size.39.ll b/amdgcn/lib/workitem/get_global_size.39.ll
deleted file mode 100644
index 967d541..0000000
--- a/amdgcn/lib/workitem/get_global_size.39.ll
+++ /dev/null
@@ -1,20 +0,0 @@
-declare i32 @llvm.r600.read.global.size.x() nounwind readnone
-declare i32 @llvm.r600.read.global.size.y() nounwind readnone
-declare i32 @llvm.r600.read.global.size.z() nounwind readnone
-
-target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-
-define i32 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
- switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
-x_dim:
- %x = call i32 @llvm.r600.read.global.size.x()
- ret i32 %x
-y_dim:
- %y = call i32 @llvm.r600.read.global.size.y()
- ret i32 %y
-z_dim:
- %z = call i32 @llvm.r600.read.global.size.z()
- ret i32 %z
-default:
- ret i32 1
-}
diff --git a/amdgcn/lib/workitem/get_global_size.40.ll b/amdgcn/lib/workitem/get_global_size.40.ll
deleted file mode 100644
index 3d26d2f..0000000
--- a/amdgcn/lib/workitem/get_global_size.40.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-declare i32 @llvm.r600.read.global.size.x() nounwind readnone
-declare i32 @llvm.r600.read.global.size.y() nounwind readnone
-declare i32 @llvm.r600.read.global.size.z() nounwind readnone
-
-target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-
-define i64 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
- switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
-x_dim:
- %x = call i32 @llvm.r600.read.global.size.x()
- %x.ext = zext i32 %x to i64
- ret i64 %x.ext
-y_dim:
- %y = call i32 @llvm.r600.read.global.size.y()
- %y.ext = zext i32 %y to i64
- ret i64 %y.ext
-z_dim:
- %z = call i32 @llvm.r600.read.global.size.z()
- %z.ext = zext i32 %z to i64
- ret i64 %z.ext
-default:
- ret i64 1
-}
diff --git a/amdgcn/lib/workitem/get_global_size.cl b/amdgcn/lib/workitem/get_global_size.cl
new file mode 100644
index 0000000..c1e3894
--- /dev/null
+++ b/amdgcn/lib/workitem/get_global_size.cl
@@ -0,0 +1,15 @@
+#include <clc/clc.h>
+
+uint __clc_amdgcn_get_global_size_x(void) __asm("llvm.r600.read.global.size.x");
+uint __clc_amdgcn_get_global_size_y(void) __asm("llvm.r600.read.global.size.y");
+uint __clc_amdgcn_get_global_size_z(void) __asm("llvm.r600.read.global.size.z");
+
+_CLC_DEF size_t get_global_size(uint dim)
+{
+ switch (dim) {
+ case 0: return __clc_amdgcn_get_global_size_x();
+ case 1: return __clc_amdgcn_get_global_size_y();
+ case 2: return __clc_amdgcn_get_global_size_z();
+ default: return 1;
+ }
+}
diff --git a/amdgcn/lib/workitem/get_global_size.ll b/amdgcn/lib/workitem/get_global_size.ll
deleted file mode 100644
index 43788ed..0000000
--- a/amdgcn/lib/workitem/get_global_size.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-declare i32 @llvm.r600.read.global.size.x() nounwind readnone
-declare i32 @llvm.r600.read.global.size.y() nounwind readnone
-declare i32 @llvm.r600.read.global.size.z() nounwind readnone
-
-target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
-
-define i64 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
- switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
-x_dim:
- %x = call i32 @llvm.r600.read.global.size.x()
- %x.ext = zext i32 %x to i64
- ret i64 %x.ext
-y_dim:
- %y = call i32 @llvm.r600.read.global.size.y()
- %y.ext = zext i32 %y to i64
- ret i64 %y.ext
-z_dim:
- %z = call i32 @llvm.r600.read.global.size.z()
- %z.ext = zext i32 %z to i64
- ret i64 %z.ext
-default:
- ret i64 1
-}
--
2.18.1
More information about the Libclc-dev
mailing list