From 68406ef34c43eac8f6ea50fcc467ce001e27ad8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20J=C3=A4=C3=A4skel=C3=A4inen?= Date: Mon, 4 Apr 2022 09:36:30 +0300 Subject: [PATCH 1/3] cl_pocl_device_side_abort rev 1 --- extensions/cl_pocl_device_side_abort.asciidoc | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 extensions/cl_pocl_device_side_abort.asciidoc diff --git a/extensions/cl_pocl_device_side_abort.asciidoc b/extensions/cl_pocl_device_side_abort.asciidoc new file mode 100644 index 00000000..0c340fcd --- /dev/null +++ b/extensions/cl_pocl_device_side_abort.asciidoc @@ -0,0 +1,117 @@ +cl_pocl_device_side_abort +========================= + +// This section needs to be after the document title. +:doctype: book +:toc2: +:toc: left +:encoding: utf-8 +:lang: en +:blank: pass:[ +] +:data-uri: +:icons: font +include::../config/attribs.txt[] +:source-highlighter: coderay + +== Name Strings + ++cl_pocl_device_side_abort+ + +== Contact + +Pekka Jääskeläinen, Parmance (pekka /at/ parmance /dot/ com) + +== Contributors + +Pekka Jääskeläinen, Parmance + +Henry Linjamäki, Parmance + +Brice Videau, Argonne National Laboratory + +== Notice + +Copyright (c) 2021-2022 Parmance + +== Status + +Early Draft + +== Version + +Built On: {docdate} + +Revision: 1 + +== Dependencies + +This extension is written against the OpenCL Specification Version 1.2, Revision 19. + +This extension requires OpenCL 1.2. + +== Overview + +With the device side abort extension, a work-item can return from the kernel +execution at any point and cause abnormal unrecoverable termination of the host +process. + +This extension differs from the cl_arm_controlled_kernel_termination extension +in that the abort in the device side is expected to behave like a call to the +POSIX abort() in the host side, terminating also the host process immediately. + +== New OpenCL C Types and Functions + +[source,c] +---- +void pocl_abort_program(void); +---- + +== Modifications to the OpenCL C Specification + +=== Add a new Section 6.12.X - "Device-side invoked platform-wide program abort" + +A new function: :: ++ +-- + +[source,c] +---- +void pocl_abort_platform(void); +---- + +Stops the kernel execution and causes an abnormal unrecoverable termination of +the host process, thus causing a abortion of execution of the whole program at +the platform level. + +Calling the device side abort also causes the printf buffer to be flushed on the +host program's standard output before aborting the host process. This allows to +implement device side assertion functionality by using the OpenCL C printf +function and this extension. + +The host should abort the process at latest when the kernel command that called +the function has finished execution, which means that all the work-items will +either call pocl_abort_program() or return from the kernel command otherwise. + +The host process is expected to call the standard abort function of the host +operating system. In POSIX/C99-compliant systems, this must be implemented by +a call to abort() which implies that the SIGABRT signal is raised and can be +caught by defining a signal handler. + +The results of an aborted kernel command are undefined. Device side abort is +guaranteed to stop the kernel command as soon as possible, even in the presence +of deadlocks or partially reached barriers in the kernel command. + +The behavior within the work-group of a kernel command with a work-item that +called the device side abort is the same as immediately returning from the +kernel for the abort-calling WI. For possible WIs that do not call abort, the +return time is undefined and can adhere to the original control flow of the +kernel as long as all the work-items eventually finish the execution. + +-- + +== Version History + +[cols="5,15,15,70"] +[grid="rows"] +[options="header"] +|==== +| Version | Date | Author | Changes +| 1 | 2022-04-08 | Pekka Jääskeläinen | *Initial revision for comments* +|==== From a05784e920e1e0da6f3f9fd78f1250f90807555e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20J=C3=A4=C3=A4skel=C3=A4inen?= Date: Mon, 25 Apr 2022 09:41:17 +0300 Subject: [PATCH 2/3] Device side abort updates and clarifications State explicitly that a compliant CPU device implementation can call abort() directly. Clarified the control flow behavior. --- extensions/cl_pocl_device_side_abort.asciidoc | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/extensions/cl_pocl_device_side_abort.asciidoc b/extensions/cl_pocl_device_side_abort.asciidoc index 0c340fcd..d8913322 100644 --- a/extensions/cl_pocl_device_side_abort.asciidoc +++ b/extensions/cl_pocl_device_side_abort.asciidoc @@ -33,12 +33,12 @@ Copyright (c) 2021-2022 Parmance == Status -Early Draft +Draft == Version Built On: {docdate} + -Revision: 1 +Revision: 2 == Dependencies @@ -48,7 +48,7 @@ This extension requires OpenCL 1.2. == Overview -With the device side abort extension, a work-item can return from the kernel +With the device side abort extension, a work-item (WI) can return from the kernel execution at any point and cause abnormal unrecoverable termination of the host process. @@ -77,7 +77,7 @@ void pocl_abort_platform(void); ---- Stops the kernel execution and causes an abnormal unrecoverable termination of -the host process, thus causing a abortion of execution of the whole program at +the host process, thus causing abortion of execution of the whole program at the platform level. Calling the device side abort also causes the printf buffer to be flushed on the @@ -86,23 +86,27 @@ implement device side assertion functionality by using the OpenCL C printf function and this extension. The host should abort the process at latest when the kernel command that called -the function has finished execution, which means that all the work-items will +the function has finished execution, which means that all the WIs will either call pocl_abort_program() or return from the kernel command otherwise. The host process is expected to call the standard abort function of the host operating system. In POSIX/C99-compliant systems, this must be implemented by a call to abort() which implies that the SIGABRT signal is raised and can be -caught by defining a signal handler. +caught by defining a signal handler. This means that a minimal implementation +of a device-side abort with a CPU device can simply call the standard abort() +directly to implement compliant behavior. The results of an aborted kernel command are undefined. Device side abort is guaranteed to stop the kernel command as soon as possible, even in the presence of deadlocks or partially reached barriers in the kernel command. -The behavior within the work-group of a kernel command with a work-item that -called the device side abort is the same as immediately returning from the -kernel for the abort-calling WI. For possible WIs that do not call abort, the -return time is undefined and can adhere to the original control flow of the -kernel as long as all the work-items eventually finish the execution. +The control flow behavior within the work-group of a kernel command with +a WI that called the device side abort is the same as immediately +returning from the kernel for the abort-calling WI at the abort call site. +For possible WIs that do not call abort, the return time is undefined and can +adhere to the original control flow of the kernel as long as all the WIs +eventually finish the execution and allow the host runtime to abort the +process also in a single-threaded/non-interrupting implementation. -- @@ -113,5 +117,7 @@ kernel as long as all the work-items eventually finish the execution. [options="header"] |==== | Version | Date | Author | Changes +| 2 | 2022-04-25 | Pekka Jääskeläinen, Brice Videau, Henry Linjamäki | +State explicitly that a compliant CPU device implementation can call abort() directly. Clarified the control flow behavior. | 1 | 2022-04-08 | Pekka Jääskeläinen | *Initial revision for comments* |==== From 152333ec3c34a054ee843e360635b1e35d33dd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20J=C3=A4=C3=A4skel=C3=A4inen?= Date: Sat, 14 May 2022 08:22:37 +0300 Subject: [PATCH 3/3] Change the device side abort to 'ext' extension --- ...idoc => cl_ext_device_side_abort.asciidoc} | 16 +- extensions/cl_ext_device_side_abort.html | 641 ++++++++++++++++++ 2 files changed, 650 insertions(+), 7 deletions(-) rename extensions/{cl_pocl_device_side_abort.asciidoc => cl_ext_device_side_abort.asciidoc} (90%) create mode 100644 extensions/cl_ext_device_side_abort.html diff --git a/extensions/cl_pocl_device_side_abort.asciidoc b/extensions/cl_ext_device_side_abort.asciidoc similarity index 90% rename from extensions/cl_pocl_device_side_abort.asciidoc rename to extensions/cl_ext_device_side_abort.asciidoc index d8913322..9d29d8ab 100644 --- a/extensions/cl_pocl_device_side_abort.asciidoc +++ b/extensions/cl_ext_device_side_abort.asciidoc @@ -1,4 +1,4 @@ -cl_pocl_device_side_abort +cl_ext_device_side_abort ========================= // This section needs to be after the document title. @@ -15,7 +15,7 @@ include::../config/attribs.txt[] == Name Strings -+cl_pocl_device_side_abort+ ++cl_ext_device_side_abort+ == Contact @@ -29,7 +29,7 @@ Brice Videau, Argonne National Laboratory == Notice -Copyright (c) 2021-2022 Parmance +Copyright (c) 2021-2022 Parmance and Argonne National Laboratory. == Status @@ -38,7 +38,7 @@ Draft == Version Built On: {docdate} + -Revision: 2 +Revision: 3 == Dependencies @@ -60,7 +60,7 @@ POSIX abort() in the host side, terminating also the host process immediately. [source,c] ---- -void pocl_abort_program(void); +void abort_platform(void); ---- == Modifications to the OpenCL C Specification @@ -73,7 +73,7 @@ A new function: :: [source,c] ---- -void pocl_abort_platform(void); +void abort_platform(void); ---- Stops the kernel execution and causes an abnormal unrecoverable termination of @@ -87,7 +87,7 @@ function and this extension. The host should abort the process at latest when the kernel command that called the function has finished execution, which means that all the WIs will -either call pocl_abort_program() or return from the kernel command otherwise. +either call abort_platform() or return from the kernel command otherwise. The host process is expected to call the standard abort function of the host operating system. In POSIX/C99-compliant systems, this must be implemented by @@ -117,6 +117,8 @@ process also in a single-threaded/non-interrupting implementation. [options="header"] |==== | Version | Date | Author | Changes +| 3 | 2022-05-14 | Pekka Jääskeläinen, Brice Videau | +*Changed to an 'ext' extension to promote multi-vendor adoption.* | 2 | 2022-04-25 | Pekka Jääskeläinen, Brice Videau, Henry Linjamäki | State explicitly that a compliant CPU device implementation can call abort() directly. Clarified the control flow behavior. | 1 | 2022-04-08 | Pekka Jääskeläinen | *Initial revision for comments* diff --git a/extensions/cl_ext_device_side_abort.html b/extensions/cl_ext_device_side_abort.html new file mode 100644 index 00000000..9f3968f1 --- /dev/null +++ b/extensions/cl_ext_device_side_abort.html @@ -0,0 +1,641 @@ + + + + + + + +cl_ext_device_side_abort + + + + + +
+
+

Name Strings

+
+
+

cl_ext_device_side_abort

+
+
+
+
+

Contact

+
+
+

Pekka Jääskeläinen, Parmance (pekka /at/ parmance /dot/ com)

+
+
+
+
+

Contributors

+
+
+

Pekka Jääskeläinen, Parmance
+Henry Linjamäki, Parmance
+Brice Videau, Argonne National Laboratory

+
+
+
+
+

Notice

+
+
+

Copyright (c) 2021-2022 Parmance and Argonne National Laboratory.

+
+
+
+
+

Status

+
+
+

Draft

+
+
+
+
+

Version

+
+
+

Built On: 2022-05-14
+Revision: 3

+
+
+
+
+

Dependencies

+
+
+

This extension is written against the OpenCL Specification Version 1.2, Revision 19.

+
+
+

This extension requires OpenCL 1.2.

+
+
+
+
+

Overview

+
+
+

With the device side abort extension, a work-item (WI) can return from the kernel +execution at any point and cause abnormal unrecoverable termination of the host +process.

+
+
+

This extension differs from the cl_arm_controlled_kernel_termination extension +in that the abort in the device side is expected to behave like a call to the +POSIX abort() in the host side, terminating also the host process immediately.

+
+
+
+
+

New OpenCL C Types and Functions

+
+
+
+
void abort_platform(void);
+
+
+
+
+
+

Modifications to the OpenCL C Specification

+
+
+

Add a new Section 6.12.X - "Device-side invoked platform-wide program abort"

+
+
+
A new function:
+
+
+
+
+
+
void abort_platform(void);
+
+
+
+

Stops the kernel execution and causes an abnormal unrecoverable termination of +the host process, thus causing abortion of execution of the whole program at +the platform level.

+
+
+

Calling the device side abort also causes the printf buffer to be flushed on the +host program’s standard output before aborting the host process. This allows to +implement device side assertion functionality by using the OpenCL C printf +function and this extension.

+
+
+

The host should abort the process at latest when the kernel command that called +the function has finished execution, which means that all the WIs will +either call abort_platform() or return from the kernel command otherwise.

+
+
+

The host process is expected to call the standard abort function of the host +operating system. In POSIX/C99-compliant systems, this must be implemented by +a call to abort() which implies that the SIGABRT signal is raised and can be +caught by defining a signal handler. This means that a minimal implementation +of a device-side abort with a CPU device can simply call the standard abort() +directly to implement compliant behavior.

+
+
+

The results of an aborted kernel command are undefined. Device side abort is +guaranteed to stop the kernel command as soon as possible, even in the presence +of deadlocks or partially reached barriers in the kernel command.

+
+
+

The control flow behavior within the work-group of a kernel command with +a WI that called the device side abort is the same as immediately +returning from the kernel for the abort-calling WI at the abort call site. +For possible WIs that do not call abort, the return time is undefined and can +adhere to the original control flow of the kernel as long as all the WIs +eventually finish the execution and allow the host runtime to abort the +process also in a single-threaded/non-interrupting implementation.

+
+
+
+
+
+
+
+
+
+
+

Version History

+
+ ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VersionDateAuthorChanges

3

2022-05-14

Pekka Jääskeläinen, Brice Videau

Changed to an ext extension to promote multi-vendor adoption.

2

2022-04-25

Pekka Jääskeläinen, Brice Videau, Henry Linjamäki

State explicitly that a compliant CPU device implementation can call abort() directly. Clarified the control flow behavior.

1

2022-04-08

Pekka Jääskeläinen

Initial revision for comments

+
+
+
+ + + \ No newline at end of file