This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use cl_amd_fp64 with AMD-stream-sdk.


Hi,

On Thu, Feb 24, 2011 at 15:32, Sebastian Pop <sebpop@gmail.com> wrote:
> Hi,
>
> On Thu, Feb 24, 2011 at 02:54, Alexey Kravets <kayrick@ispras.ru> wrote:
>> For example to check for errors in generated OpenCL code, try the following
>> command.
>> strace -s 9999 ./a.out 2>&1|grep -i error | xargs -0 printf
>>
>
> This seems to be the right tool to debug my crashes: I got this
> error: can't enable all OpenCL extensions or
>          unrecognized OpenCL extension
>  #pragma OPENCL EXTENSION cl_khr_fp64  : enable
>
> I see that this is not supported on the ATI stream-sdk.

I see in the OpenCL spec this paragraph:

An extension which adds the extension string "cl_khr_fp64" should also
add a preprocessor
#define called cl_khr_fp64. A kernel can now use this preprocessor #define to do
something like:
      #ifdef cl_khr_fp64
             // do something using the extension
      #else
             // do something else or #error!
      #endif

I tested by hand the following patch, and it fixed the problems that I
saw previously with the ATI-stream-SDK.  I committed the patch to the
graphite branch.

Thanks Alexey for the hint on how to debug the OpenCL code!

Sebastian

2011-01-25  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-opencl.c (opencl_create_function_call): Use cl_khr_fp64
	pragma extension only when it is defined.  Use cl_amd_fp64 when it
	is defined.
---
 gcc/ChangeLog.graphite |    6 ++++++
 gcc/graphite-opencl.c  |    9 +++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 05742ec..b1fa8ca 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,9 @@
+2011-01-25  Sebastian Pop  <sebastian.pop@amd.com>
+
+	* graphite-opencl.c (opencl_create_function_call): Use cl_khr_fp64
+	pragma extension only when it is defined.  Use cl_amd_fp64 when it
+	is defined.
+
 2011-01-23  Tobias Grosser  <grosser@fim.uni-passau.de>
 
 	* doc/install.texi: Replace '/' by an or and give the exact
diff --git a/gcc/graphite-opencl.c b/gcc/graphite-opencl.c
index 7a477ca..ea894ee 100644
--- a/gcc/graphite-opencl.c
+++ b/gcc/graphite-opencl.c
@@ -1641,8 +1641,13 @@ opencl_create_function_call (edge base)
     (main_program_src,
      "#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable\n");
   /* Required for double type.  */
-  dyn_string_prepend_cstr
-    (main_program_src, "#pragma OPENCL EXTENSION cl_khr_fp64  : enable\n ");
+  dyn_string_prepend_cstr (main_program_src,
+			   "#if defined(cl_khr_fp64)\n"
+			   "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"
+			   "#elif defined(cl_amd_fp64)\n"
+			   "#pragma OPENCL EXTENSION cl_amd_fp64 : enable\n"
+			   "#endif\n");
+
   src = dyn_string_buf (main_program_src);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]