From a3bd1c8e5034daa46294620f50fedccd1aaf83c6 Mon Sep 17 00:00:00 2001
From: Barney <barney@frontofficedeveloper.com>
Date: Sun, 13 Sep 2015 12:49:42 +0100
Subject: [PATCH] Fix to allow use of __private memory space on NVidia devices

---
 .../com/amd/aparapi/internal/writer/KernelWriter.java    | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/internal/writer/KernelWriter.java b/com.amd.aparapi/src/java/com/amd/aparapi/internal/writer/KernelWriter.java
index 92ce2fe9..16763ccb 100644
--- a/com.amd.aparapi/src/java/com/amd/aparapi/internal/writer/KernelWriter.java
+++ b/com.amd.aparapi/src/java/com/amd/aparapi/internal/writer/KernelWriter.java
@@ -73,6 +73,11 @@ public abstract class KernelWriter extends BlockWriter{
 
    private final String cvtShortArrayToShortStar = "short* ";
 
+   /** When declaring a __private struct pointer field, we always omit the "__private" qualifier. This is because the NVidia OpenCL compiler, at time of writing
+    * erroneously complains about explicitly qualifying pointers with __private ("error: field may not be qualified with an address space").
+    */
+   private static final boolean IMPLICIT_PRIVATE_FIELDS = true;
+
    // private static Logger logger = Logger.getLogger(Config.getLoggerName());
 
    private Entrypoint entryPoint = null;
@@ -333,7 +338,9 @@ public abstract class KernelWriter extends BlockWriter{
          while (signature.startsWith("[")) {
             if (isPointer == false) {
                argLine.append(argType + " ");
-               thisStructLine.append(type + " ");
+               if (!(type.equals(__private) && IMPLICIT_PRIVATE_FIELDS)) {
+                  thisStructLine.append(type + " ");
+               }
             }
             isPointer = true;
             numDimensions++;
-- 
GitLab