[Libclc-dev] [PATCH 1/5] amdgcn: Convert get_local_size to clc
Jan Vesely via Libclc-dev
libclc-dev at lists.llvm.org
Sun Oct 28 23:43:01 PDT 2018
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
Similar to the previous series, this one consolidates various llvm asm
implementations into clc files. The code generated by llvm5 for
global-memory.cl and local-memory.cl piglits is identical.
The code for get-global-size.cl, get-local-size.cl, and
get-num-groups.cl is slightly different as the current code added an
extra 'and' operation when retrieving Zdimension local-size:
%z_size = load i32, i32 addrspace(2)* %z_size_ptr, align 4, !invariant.load !0, !range !1
%z_size.ext = zext i32 %z_size to i64
was changed to:
return ptr[2] & 0xffffu;
Although I don't think the high bytes will every be anythin other than
zeros, I think the latter is a bit more correct.
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_local_size.39.ll | 20 --------------------
amdgcn/lib/workitem/get_local_size.40.ll | 23 -----------------------
amdgcn/lib/workitem/get_local_size.cl | 15 +++++++++++++++
amdgcn/lib/workitem/get_local_size.ll | 23 -----------------------
13 files changed, 16 insertions(+), 75 deletions(-)
delete mode 100644 amdgcn/lib/workitem/get_local_size.39.ll
delete mode 100644 amdgcn/lib/workitem/get_local_size.40.ll
create mode 100644 amdgcn/lib/workitem/get_local_size.cl
delete mode 100644 amdgcn/lib/workitem/get_local_size.ll
diff --git a/amdgcn/lib/OVERRIDES_3.9 b/amdgcn/lib/OVERRIDES_3.9
index 3268f67..ed6c06d 100644
--- a/amdgcn/lib/OVERRIDES_3.9
+++ b/amdgcn/lib/OVERRIDES_3.9
@@ -1,4 +1,3 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
workitem/get_global_size.ll
-workitem/get_local_size.ll
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/OVERRIDES_4.0 b/amdgcn/lib/OVERRIDES_4.0
index 3268f67..ed6c06d 100644
--- a/amdgcn/lib/OVERRIDES_4.0
+++ b/amdgcn/lib/OVERRIDES_4.0
@@ -1,4 +1,3 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
workitem/get_global_size.ll
-workitem/get_local_size.ll
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/OVERRIDES_5.0 b/amdgcn/lib/OVERRIDES_5.0
index 3268f67..ed6c06d 100644
--- a/amdgcn/lib/OVERRIDES_5.0
+++ b/amdgcn/lib/OVERRIDES_5.0
@@ -1,4 +1,3 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
workitem/get_global_size.ll
-workitem/get_local_size.ll
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/OVERRIDES_6.0 b/amdgcn/lib/OVERRIDES_6.0
index 3268f67..ed6c06d 100644
--- a/amdgcn/lib/OVERRIDES_6.0
+++ b/amdgcn/lib/OVERRIDES_6.0
@@ -1,4 +1,3 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
workitem/get_global_size.ll
-workitem/get_local_size.ll
workitem/get_num_groups.ll
diff --git a/amdgcn/lib/SOURCES b/amdgcn/lib/SOURCES
index f78a272..8e9fdde 100644
--- a/amdgcn/lib/SOURCES
+++ b/amdgcn/lib/SOURCES
@@ -12,6 +12,6 @@ workitem/get_global_offset.cl
workitem/get_group_id.cl
workitem/get_global_size.ll
workitem/get_local_id.cl
-workitem/get_local_size.ll
+workitem/get_local_size.cl
workitem/get_num_groups.ll
workitem/get_work_dim.cl
diff --git a/amdgcn/lib/SOURCES_3.9 b/amdgcn/lib/SOURCES_3.9
index 3cecdb0..8b2a255 100644
--- a/amdgcn/lib/SOURCES_3.9
+++ b/amdgcn/lib/SOURCES_3.9
@@ -1,5 +1,4 @@
cl_khr_int64_extended_atomics/minmax_helpers.39.ll
mem_fence/waitcnt.ll
workitem/get_global_size.39.ll
-workitem/get_local_size.39.ll
workitem/get_num_groups.39.ll
diff --git a/amdgcn/lib/SOURCES_4.0 b/amdgcn/lib/SOURCES_4.0
index 5ed1d7c..5342d54 100644
--- a/amdgcn/lib/SOURCES_4.0
+++ b/amdgcn/lib/SOURCES_4.0
@@ -1,5 +1,4 @@
cl_khr_int64_extended_atomics/minmax_helpers.39.ll
mem_fence/waitcnt.ll
workitem/get_global_size.40.ll
-workitem/get_local_size.40.ll
workitem/get_num_groups.40.ll
diff --git a/amdgcn/lib/SOURCES_5.0 b/amdgcn/lib/SOURCES_5.0
index 45c51ec..0977b32 100644
--- a/amdgcn/lib/SOURCES_5.0
+++ b/amdgcn/lib/SOURCES_5.0
@@ -1,4 +1,3 @@
cl_khr_int64_extended_atomics/minmax_helpers.39.ll
workitem/get_global_size.40.ll
-workitem/get_local_size.40.ll
workitem/get_num_groups.40.ll
diff --git a/amdgcn/lib/SOURCES_6.0 b/amdgcn/lib/SOURCES_6.0
index 45c51ec..0977b32 100644
--- a/amdgcn/lib/SOURCES_6.0
+++ b/amdgcn/lib/SOURCES_6.0
@@ -1,4 +1,3 @@
cl_khr_int64_extended_atomics/minmax_helpers.39.ll
workitem/get_global_size.40.ll
-workitem/get_local_size.40.ll
workitem/get_num_groups.40.ll
diff --git a/amdgcn/lib/workitem/get_local_size.39.ll b/amdgcn/lib/workitem/get_local_size.39.ll
deleted file mode 100644
index 4fe483a..0000000
--- a/amdgcn/lib/workitem/get_local_size.39.ll
+++ /dev/null
@@ -1,20 +0,0 @@
-declare i32 @llvm.r600.read.local.size.x() nounwind readnone
-declare i32 @llvm.r600.read.local.size.y() nounwind readnone
-declare i32 @llvm.r600.read.local.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_local_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.local.size.x()
- ret i32 %x
-y_dim:
- %y = call i32 @llvm.r600.read.local.size.y()
- ret i32 %y
-z_dim:
- %z = call i32 @llvm.r600.read.local.size.z()
- ret i32 %z
-default:
- ret i32 1
-}
diff --git a/amdgcn/lib/workitem/get_local_size.40.ll b/amdgcn/lib/workitem/get_local_size.40.ll
deleted file mode 100644
index 36141f9..0000000
--- a/amdgcn/lib/workitem/get_local_size.40.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-declare i32 @llvm.r600.read.local.size.x() nounwind readnone
-declare i32 @llvm.r600.read.local.size.y() nounwind readnone
-declare i32 @llvm.r600.read.local.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_local_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.local.size.x()
- %x.ext = zext i32 %x to i64
- ret i64 %x.ext
-y_dim:
- %y = call i32 @llvm.r600.read.local.size.y()
- %y.ext = zext i32 %y to i64
- ret i64 %y.ext
-z_dim:
- %z = call i32 @llvm.r600.read.local.size.z()
- %z.ext = zext i32 %z to i64
- ret i64 %z.ext
-default:
- ret i64 1
-}
diff --git a/amdgcn/lib/workitem/get_local_size.cl b/amdgcn/lib/workitem/get_local_size.cl
new file mode 100644
index 0000000..9b19f6b
--- /dev/null
+++ b/amdgcn/lib/workitem/get_local_size.cl
@@ -0,0 +1,15 @@
+#include <clc/clc.h>
+
+uint __clc_amdgcn_get_local_size_x(void) __asm("llvm.r600.read.local.size.x");
+uint __clc_amdgcn_get_local_size_y(void) __asm("llvm.r600.read.local.size.y");
+uint __clc_amdgcn_get_local_size_z(void) __asm("llvm.r600.read.local.size.z");
+
+_CLC_DEF size_t get_local_size(uint dim)
+{
+ switch (dim) {
+ case 0: return __clc_amdgcn_get_local_size_x();
+ case 1: return __clc_amdgcn_get_local_size_y();
+ case 2: return __clc_amdgcn_get_local_size_z();
+ default: return 1;
+ }
+}
diff --git a/amdgcn/lib/workitem/get_local_size.ll b/amdgcn/lib/workitem/get_local_size.ll
deleted file mode 100644
index 988c4cb..0000000
--- a/amdgcn/lib/workitem/get_local_size.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-declare i32 @llvm.r600.read.local.size.x() nounwind readnone
-declare i32 @llvm.r600.read.local.size.y() nounwind readnone
-declare i32 @llvm.r600.read.local.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_local_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.local.size.x()
- %x.ext = zext i32 %x to i64
- ret i64 %x.ext
-y_dim:
- %y = call i32 @llvm.r600.read.local.size.y()
- %y.ext = zext i32 %y to i64
- ret i64 %y.ext
-z_dim:
- %z = call i32 @llvm.r600.read.local.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