cl: Add test for call stack realignment

Submitted by Matt Arsenault on Aug. 13, 2018, 8:33 p.m.

Details

Message ID 20180813203305.3702-1-arsenm2@gmail.com
State New
Headers show
Series "cl: Add test for call stack realignment" ( rev: 2 ) in Piglit

Not browsing as part of any series.

Commit Message

Matt Arsenault Aug. 13, 2018, 8:33 p.m.
v2: Use uintptr_t

v3: Formatting
---
 tests/cl/program/execute/realign-stack.cl | 93 +++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 tests/cl/program/execute/realign-stack.cl

Patch hide | download patch | download mbox

diff --git a/tests/cl/program/execute/realign-stack.cl b/tests/cl/program/execute/realign-stack.cl
new file mode 100644
index 000000000..ca83284fe
--- /dev/null
+++ b/tests/cl/program/execute/realign-stack.cl
@@ -0,0 +1,93 @@ 
+/*!
+
+[config]
+name: call with stack realignment
+
+[test]
+name: call stack realignment 16
+kernel_name: kernel_call_stack_realign16_func
+dimensions: 1
+global_size: 1 0 0
+
+arg_out: 0 buffer int[1] 1
+
+
+[test]
+name: call stack realignment 32
+kernel_name: kernel_call_stack_realign32_func
+dimensions: 1
+global_size: 1 0 0
+
+arg_out: 0 buffer int[1] 1
+
+[test]
+name: call stack realignment 64
+kernel_name: kernel_call_stack_realign64_func
+dimensions: 1
+global_size: 1 0 0
+
+arg_out: 0 buffer int[1] 1
+
+[test]
+name: call stack realignment 128
+kernel_name: kernel_call_stack_realign128_func
+dimensions: 1
+global_size: 1 0 0
+
+arg_out: 0 buffer int[1] 1
+
+
+!*/
+
+// Make sure the absolute private address of stack objects in callee
+// functions is properly aligned.
+
+#define NOINLINE __attribute__((noinline))
+
+NOINLINE
+int test_stack_object_alignment16() {
+    volatile int4 requires_align16 = 0;
+    volatile uintptr_t addr = (uint)&requires_align16;
+    return (addr & 15) == 0;
+}
+
+NOINLINE
+int test_stack_object_alignment32() {
+    volatile int8 requires_align32 = 0;
+    volatile uintptr_t addr = (uint)&requires_align32;
+    return (addr & 31) == 0;
+}
+
+NOINLINE
+int test_stack_object_alignment64() {
+    volatile int16 requires_align64 = 0;
+    volatile uintptr_t addr = (uint)&requires_align64;
+    return (addr & 63) == 0;
+}
+
+NOINLINE
+int test_stack_object_alignment128() {
+    volatile long16 requires_align128 = 0;
+    volatile uintptr_t addr = (uint)&requires_align128;
+    return (addr & 127) == 0;
+}
+
+kernel void kernel_call_stack_realign16_func(global int* out) {
+    volatile int misalign_stack = 0;
+    *out = test_stack_object_alignment16();
+}
+
+kernel void kernel_call_stack_realign32_func(global int* out) {
+    volatile int misalign_stack = 0;
+    *out = test_stack_object_alignment32();
+}
+
+kernel void kernel_call_stack_realign64_func(global int* out) {
+    volatile int misalign_stack = 0;
+    *out = test_stack_object_alignment64();
+}
+
+kernel void kernel_call_stack_realign128_func(global int* out) {
+    volatile int misalign_stack = 0;
+    *out = test_stack_object_alignment128();
+}

Comments

ping

> On Aug 13, 2018, at 23:33, Matt Arsenault <arsenm2@gmail.com> wrote:
> 
> v2: Use uintptr_t
> 
> v3: Formatting
> ---
> tests/cl/program/execute/realign-stack.cl | 93 +++++++++++++++++++++++
> 1 file changed, 93 insertions(+)
> create mode 100644 tests/cl/program/execute/realign-stack.cl
> 
> diff --git a/tests/cl/program/execute/realign-stack.cl b/tests/cl/program/execute/realign-stack.cl
> new file mode 100644
> index 000000000..ca83284fe
> --- /dev/null
> +++ b/tests/cl/program/execute/realign-stack.cl
> @@ -0,0 +1,93 @@
> +/*!
> +
> +[config]
> +name: call with stack realignment
> +
> +[test]
> +name: call stack realignment 16
> +kernel_name: kernel_call_stack_realign16_func
> +dimensions: 1
> +global_size: 1 0 0
> +
> +arg_out: 0 buffer int[1] 1
> +
> +
> +[test]
> +name: call stack realignment 32
> +kernel_name: kernel_call_stack_realign32_func
> +dimensions: 1
> +global_size: 1 0 0
> +
> +arg_out: 0 buffer int[1] 1
> +
> +[test]
> +name: call stack realignment 64
> +kernel_name: kernel_call_stack_realign64_func
> +dimensions: 1
> +global_size: 1 0 0
> +
> +arg_out: 0 buffer int[1] 1
> +
> +[test]
> +name: call stack realignment 128
> +kernel_name: kernel_call_stack_realign128_func
> +dimensions: 1
> +global_size: 1 0 0
> +
> +arg_out: 0 buffer int[1] 1
> +
> +
> +!*/
> +
> +// Make sure the absolute private address of stack objects in callee
> +// functions is properly aligned.
> +
> +#define NOINLINE __attribute__((noinline))
> +
> +NOINLINE
> +int test_stack_object_alignment16() {
> +    volatile int4 requires_align16 = 0;
> +    volatile uintptr_t addr = (uint)&requires_align16;
> +    return (addr & 15) == 0;
> +}
> +
> +NOINLINE
> +int test_stack_object_alignment32() {
> +    volatile int8 requires_align32 = 0;
> +    volatile uintptr_t addr = (uint)&requires_align32;
> +    return (addr & 31) == 0;
> +}
> +
> +NOINLINE
> +int test_stack_object_alignment64() {
> +    volatile int16 requires_align64 = 0;
> +    volatile uintptr_t addr = (uint)&requires_align64;
> +    return (addr & 63) == 0;
> +}
> +
> +NOINLINE
> +int test_stack_object_alignment128() {
> +    volatile long16 requires_align128 = 0;
> +    volatile uintptr_t addr = (uint)&requires_align128;
> +    return (addr & 127) == 0;
> +}
> +
> +kernel void kernel_call_stack_realign16_func(global int* out) {
> +    volatile int misalign_stack = 0;
> +    *out = test_stack_object_alignment16();
> +}
> +
> +kernel void kernel_call_stack_realign32_func(global int* out) {
> +    volatile int misalign_stack = 0;
> +    *out = test_stack_object_alignment32();
> +}
> +
> +kernel void kernel_call_stack_realign64_func(global int* out) {
> +    volatile int misalign_stack = 0;
> +    *out = test_stack_object_alignment64();
> +}
> +
> +kernel void kernel_call_stack_realign128_func(global int* out) {
> +    volatile int misalign_stack = 0;
> +    *out = test_stack_object_alignment128();
> +}
> -- 
> 2.17.1
>
On Tue, 2018-08-21 at 21:00 +0300, Matt Arsenault wrote:
> ping

sorry. I won't have access to my machines until next week (possibly
September)

> 
> > On Aug 13, 2018, at 23:33, Matt Arsenault <arsenm2@gmail.com> wrote:
> > 
> > v2: Use uintptr_t
> > 
> > v3: Formatting
> > ---
> > tests/cl/program/execute/realign-stack.cl | 93 +++++++++++++++++++++++
> > 1 file changed, 93 insertions(+)
> > create mode 100644 tests/cl/program/execute/realign-stack.cl
> > 
> > diff --git a/tests/cl/program/execute/realign-stack.cl b/tests/cl/program/execute/realign-stack.cl
> > new file mode 100644
> > index 000000000..ca83284fe
> > --- /dev/null
> > +++ b/tests/cl/program/execute/realign-stack.cl
> > @@ -0,0 +1,93 @@
> > +/*!
> > +
> > +[config]
> > +name: call with stack realignment
> > +
> > +[test]
> > +name: call stack realignment 16
> > +kernel_name: kernel_call_stack_realign16_func
> > +dimensions: 1
> > +global_size: 1 0 0
> > +
> > +arg_out: 0 buffer int[1] 1
> > +
> > +
> > +[test]
> > +name: call stack realignment 32
> > +kernel_name: kernel_call_stack_realign32_func
> > +dimensions: 1
> > +global_size: 1 0 0
> > +
> > +arg_out: 0 buffer int[1] 1
> > +
> > +[test]
> > +name: call stack realignment 64
> > +kernel_name: kernel_call_stack_realign64_func
> > +dimensions: 1
> > +global_size: 1 0 0
> > +
> > +arg_out: 0 buffer int[1] 1
> > +
> > +[test]
> > +name: call stack realignment 128
> > +kernel_name: kernel_call_stack_realign128_func
> > +dimensions: 1
> > +global_size: 1 0 0
> > +
> > +arg_out: 0 buffer int[1] 1
> > +
> > +
> > +!*/
> > +
> > +// Make sure the absolute private address of stack objects in callee
> > +// functions is properly aligned.
> > +
> > +#define NOINLINE __attribute__((noinline))
> > +
> > +NOINLINE
> > +int test_stack_object_alignment16() {
> > +    volatile int4 requires_align16 = 0;
> > +    volatile uintptr_t addr = (uint)&requires_align16;

The cast should probably be (uintptr_t) as well, right?

> > +    return (addr & 15) == 0;

The test would be clearer if these constants were in hex (0xf)

Jan

> > +}
> > +
> > +NOINLINE
> > +int test_stack_object_alignment32() {
> > +    volatile int8 requires_align32 = 0;
> > +    volatile uintptr_t addr = (uint)&requires_align32;
> > +    return (addr & 31) == 0;
> > +}
> > +
> > +NOINLINE
> > +int test_stack_object_alignment64() {
> > +    volatile int16 requires_align64 = 0;
> > +    volatile uintptr_t addr = (uint)&requires_align64;
> > +    return (addr & 63) == 0;
> > +}
> > +
> > +NOINLINE
> > +int test_stack_object_alignment128() {
> > +    volatile long16 requires_align128 = 0;
> > +    volatile uintptr_t addr = (uint)&requires_align128;
> > +    return (addr & 127) == 0;
> > +}
> > +
> > +kernel void kernel_call_stack_realign16_func(global int* out) {
> > +    volatile int misalign_stack = 0;
> > +    *out = test_stack_object_alignment16();
> > +}
> > +
> > +kernel void kernel_call_stack_realign32_func(global int* out) {
> > +    volatile int misalign_stack = 0;
> > +    *out = test_stack_object_alignment32();
> > +}
> > +
> > +kernel void kernel_call_stack_realign64_func(global int* out) {
> > +    volatile int misalign_stack = 0;
> > +    *out = test_stack_object_alignment64();
> > +}
> > +
> > +kernel void kernel_call_stack_realign128_func(global int* out) {
> > +    volatile int misalign_stack = 0;
> > +    *out = test_stack_object_alignment128();
> > +}
> > -- 
> > 2.17.1
> > 
> 
>
> On Aug 22, 2018, at 10:57, Jan Vesely <jan.vesely@rutgers.edu> wrote:
> 
> On Tue, 2018-08-21 at 21:00 +0300, Matt Arsenault wrote:
>> ping
> 
> sorry. I won't have access to my machines until next week (possibly
> September)
ping
On Wed, 2018-09-05 at 19:15 +0500, Matt Arsenault wrote:
> > On Aug 22, 2018, at 10:57, Jan Vesely <jan.vesely@rutgers.edu> wrote:
> > 
> > On Tue, 2018-08-21 at 21:00 +0300, Matt Arsenault wrote:
> > > ping
> > 
> > sorry. I won't have access to my machines until next week (possibly
> > September)
> 
> ping

I've merged the others, this one did not address the latest comment;
casts should be to (uintptr_t) as rather tan (uint).
 volatile uintptr_t addr = (uint)&... ->  volatile uintptr_t addr = (uintptr_t)&

Jan
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit