File: AMDSDK.patch

package info (click to toggle)
pocl 6.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,320 kB
  • sloc: lisp: 149,513; ansic: 103,778; cpp: 54,947; python: 1,513; sh: 949; ruby: 255; pascal: 226; tcl: 180; makefile: 175; java: 72; xml: 49
file content (508 lines) | stat: -rw-r--r-- 15,847 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
diff --git a/AMD-APP-SDK-v2.8-RC-lnx64/make/openclsdkdefs.mk b/AMD-APP-SDK-v2.8-RC-lnx64/make/openclsdkdefs.mk
index bab044a..f17f393 100755
--- a/AMD-APP-SDK-v2.8-RC-lnx64/make/openclsdkdefs.mk
+++ b/AMD-APP-SDK-v2.8-RC-lnx64/make/openclsdkdefs.mk
@@ -31,7 +31,7 @@ else
    endif
 endif
 
-
+ISINTEL = true
 # What CPU and mode?
 ifeq ($(findstring WOW64, $(UNAME)), WOW64)
   BITS = 64
@@ -45,12 +45,21 @@ else
 ifeq ($(findstring x86_64, $(UNAME)), x86_64)
   BITS = 64
 else
+ifeq ($(findstring ppc, $(UNAME)), ppc)
+  BITS = 32
+  ISINTEL = false
+else
+ifeq ($(findstring armv, $(UNAME)), armv)
+  BITS = 32
+  ISINTEL = false
+else
   $(error Unknown CPU)
 endif
 endif
 endif
 endif
-
+endif
+endif
 # Override bitness with user specified value 
 ifdef bitness 
 ifeq ($(bitness), 32)
@@ -231,11 +240,6 @@ endif
 	CPPAMP_LLIBS   := 
 else 
 ifeq ($(OS), lnx) # Linux settings 
-  ifeq ($(BITS), 64)
-  else
-    CFLAGS += -m32 -msse2
-    LDFLAGS += -m32
-  endif
 ifdef INTEL
   CC                := icpc
 else
@@ -263,7 +267,7 @@ endif
 ifdef MINGW
   LDFLAGS           += -L/usr/X11R6/lib 
 else
-  LDFLAGS           += -lpthread -ldl -L/usr/X11R6/lib 
+  LDFLAGS           += -lpthread -ldl -L/usr/X11R6/lib $(shell pkg-config --silence-errors --libs-only-L ocl-icd sdl)
 endif
   LD_LIBDIR_FLAG    := -L
   LD_SHARED_FLAG    := -shared   
@@ -305,7 +309,8 @@ endif
 BUILDDIR := build
 DEBUG_DIR := debug
 RELEASE_DIR := release
-X86_DIR := x86
+#we don't want to have a separate directory for each platform, and we don't expect to do multi arch builds in pocl
+X86_DIR := x86_64
 X86_64_DIR := x86_64
 ifeq ($(BITS), 64)
 CPU_ARCH = x86_64
@@ -325,7 +330,8 @@ BOLT_LIBDIRS = "$(AMDAPPSDKROOT)/lib/$(CPU_ARCH)"
 CAL_LIBDIRS = "$(AMDAPPSDKROOT)/lib"
 CPPAMP_LIBDIRS = 
 
-LIBDIRS = $(DEPTH)/lib/$(CPU_ARCH) $(DEPTH)/TempSDKUtil/lib/$(CPU_ARCH) 
+#LIBDIRS = $(DEPTH)/lib/$(CPU_ARCH)
+LIBDIRS = $(DEPTH)/TempSDKUtil/lib/$(CPU_ARCH) 
 CL_SUFFIX	   	   := .cl
 CLC				   := clc
 
diff --git a/AMD-APP-SDK-v2.8-RC-lnx64/make/openclsdkrules.mk b/AMD-APP-SDK-v2.8-RC-lnx64/make/openclsdkrules.mk
index 606d035..a5c6152 100755
--- a/AMD-APP-SDK-v2.8-RC-lnx64/make/openclsdkrules.mk
+++ b/AMD-APP-SDK-v2.8-RC-lnx64/make/openclsdkrules.mk
@@ -132,7 +132,7 @@ endif
 endif
 
 
-LDFLAGS += $(ADDSDKLIBS) 
+LDFLAGS += $(ADDSDKLIBS) -lSDL
 LDFLAGS += $(ADDSDKLIBDIRS) 
 CFLAGS += $(ADDSDKINCDIRS) 
 
diff --git a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/SDKUtil/SDKApplication.cpp b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/SDKUtil/SDKApplication.cpp
index 1d37f9d..8d18be9 100755
--- a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/SDKUtil/SDKApplication.cpp
+++ b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/SDKUtil/SDKApplication.cpp
@@ -345,7 +345,8 @@ int SDKSample::validatePlatformAndDeviceOptions()
                 gpu = false;
             }
 
-            clReleaseContext(context);
+            if (context != NULL)
+                clReleaseContext(context);
         }
 
         // Get device count
diff --git a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/SDKUtil/SDKBitMap.cpp b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/SDKUtil/SDKBitMap.cpp
index 9e7215e..a905c75 100755
--- a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/SDKUtil/SDKBitMap.cpp
+++ b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/SDKUtil/SDKBitMap.cpp
@@ -14,6 +14,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ********************************************************************/
 #include "SDKBitMap.hpp"
+#include <SDL/SDL.h>
 static const short bitMapID = 19778;
 
 namespace streamsdk
@@ -92,76 +93,28 @@ SDKBitMap& SDKBitMap::operator=(const SDKBitMap& rhs)
 
 bool SDKBitMap::write(const char * filename, int width, int height, unsigned int *ptr)
 {
-    // Open BMP file
-    FILE * fd = fopen(filename, "wb");
-
-    int alignSize  = width * 4;
-    alignSize ^= 0x03;
-    alignSize ++;
-    alignSize &= 0x03;
-
-    int rowLength = width * 4 + alignSize;
+    SDL_Surface* the_bmp=SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24, 0, 0, 0, 0);
 
     // Opened OK
-    if (fd != NULL) 
+    if (the_bmp != NULL) 
     {
-        BitMapHeader *bitMapHeader = new BitMapHeader;
-        bitMapHeader->id = bitMapID;
-        bitMapHeader->offset = sizeof(BitMapHeader) + sizeof(BitMapInfoHeader);
-        bitMapHeader->reserved1 = 0x0000;
-        bitMapHeader->reserved2 = 0x0000;
-        bitMapHeader->size = sizeof(BitMapHeader) + sizeof(BitMapInfoHeader) + rowLength * height;
-        // Write header
-        fwrite(bitMapHeader, sizeof(BitMapHeader), 1, fd);
-
-        // Failed to write header
-        if (ferror(fd)) 
-        {
-            fclose(fd);
-            return false;
-        }
-
-        BitMapInfoHeader *bitMapInfoHeader = new BitMapInfoHeader;
-        bitMapInfoHeader->bitsPerPixel = 32;
-        bitMapInfoHeader->clrImportant = 0;
-        bitMapInfoHeader->clrUsed = 0;
-        bitMapInfoHeader->compression = 0;
-        bitMapInfoHeader->height = height;
-        bitMapInfoHeader->imageSize = rowLength * height;
-        bitMapInfoHeader->planes = 1;
-        bitMapInfoHeader->sizeInfo = sizeof(BitMapInfoHeader);
-        bitMapInfoHeader->width = width; 
-        bitMapInfoHeader->xPelsPerMeter = 0;
-        bitMapInfoHeader->yPelsPerMeter = 0;
-
-        // Write map info header
-        fwrite(bitMapInfoHeader, sizeof(BitMapInfoHeader), 1, fd);
-
-        // Failed to write map info header
-        if (ferror(fd)) 
-        {
-            fclose(fd);
-            return false;
-        }    
         unsigned char buffer[4];
         int x, y;
 
+        unsigned index=0;
         for (y = 0; y < height; y++)
         {
             for (x = 0; x < width; x++, ptr++)
             {
-                if( 4 != fwrite(ptr, 1, 4, fd)) 
-                {
-                    fclose(fd);
-                    return false;
-                }
+                uchar4 *the_pixel = (uchar4*)ptr;
+                ((char*)(the_bmp->pixels))[index++]=the_pixel->x;
+                ((char*)(the_bmp->pixels))[index++]=the_pixel->y;
+                ((char*)(the_bmp->pixels))[index++]=the_pixel->z;
+                
             }
-            memset( buffer, 0x00, 4 );
-
-            fwrite( buffer, 1, alignSize, fd );
         }
 
-        fclose( fd );
+        SDL_SaveBMP(the_bmp, filename);
         return true;
     }
 
@@ -186,106 +139,30 @@ SDKBitMap::load(const char * filename)
 {
     // Release any existing resources
     releaseResources();
-
+    
+    SDL_Surface *the_bmp=SDL_LoadBMP(filename);
     // Open BMP file
-    FILE * fd = fopen(filename, "rb");
+    //FILE * fd = fopen(filename, "rb");
     // FILE *fd; 
     //fopen_s(&fd, filename, "rb");
 
     // Opened OK
-    if (fd != NULL) {
-        // Read header
-        fread((BitMapHeader *)this, sizeof(BitMapHeader), 1, fd);
-
-        // Failed to read header
-        if (ferror(fd)) {
-            fclose(fd);
-            return;
-        }
-
-        // Confirm that we have a bitmap file
-        if (id != bitMapID) {
-            fclose(fd);
-            return;
-        }
+    if (the_bmp != NULL) {
 
-        // Read map info header
-        fread((BitMapInfoHeader *)this, sizeof(BitMapInfoHeader), 1, fd);
-
-        // Failed to read map info header
-        if (ferror(fd)) {
-            fclose(fd);
-            return;
-        }
-
-        // No support for compressed images
-        if (compression) {
-            fclose(fd);
-            return;
-        }
-
-        // Support only 8 or 24 bits images
-        if (bitsPerPixel < 8) {
-            fclose(fd);
-            return;
-        }
+        bitsPerPixel = the_bmp->format->BitsPerPixel;
+        width = the_bmp->w;
+        height = the_bmp->h;
 
         // Store number of colors
         numColors_ = 1 << bitsPerPixel;
 
-        //load the palate for 8 bits per pixel
-        if(bitsPerPixel == 8) {
-            colors_ = new ColorPalette[numColors_];
-            if (colors_ == NULL) {
-                fclose(fd);
-                return;
-            }
-            fread(
-                (char *)colors_,
-                numColors_ * sizeof(ColorPalette),
-                1,
-                fd);
-
-            // Failed to read colors
-            if (ferror(fd)) {
-                fclose(fd);
-                return;
-            }
-        }
-
         // Allocate buffer to hold all pixels
         unsigned int sizeBuffer = size - offset;
-        unsigned char * tmpPixels = new unsigned char[sizeBuffer];
-
-        if (tmpPixels == NULL) {
-            delete colors_;
-            colors_ = NULL;
-            fclose(fd);
-            return;
-        }
-
-        // Read pixels from file, including any padding
-        fread(tmpPixels, sizeBuffer * sizeof(unsigned char), 1, fd);
-
-        // Failed to read pixel data
-        if (ferror(fd)) {
-            delete colors_;
-            colors_ = NULL;
-            delete tmpPixels;
-            fclose(fd);
-            return;
-        }
 
         // Allocate image
         pixels_ = new uchar4[width * height];
-        if (pixels_ == NULL) {
-            delete colors_;
-            colors_ = NULL;
-            delete tmpPixels;
-            fclose(fd);
-            return;
-        }
-        // Set image, including w component (white)
+
+       // Set image, including w component (white)
         memset(pixels_, 0xff, width * height * sizeof(uchar4));
 
         unsigned int index = 0;
@@ -293,12 +170,12 @@ SDKBitMap::load(const char * filename)
             for(int x = 0; x < width; x++) {
                 // Read RGB values
                 if (bitsPerPixel == 8) {
-                    pixels_[(y * width + x)] = colors_[tmpPixels[index++]];
+                    //turns out the SDK samples don't have any 8 bpp bmps... :)
                 }
                 else { // 24 bit
-                    pixels_[(y * width + x)].z = tmpPixels[index++];
-                    pixels_[(y * width + x)].y = tmpPixels[index++];
-                    pixels_[(y * width + x)].x = tmpPixels[index++];
+                    pixels_[(y * width + x)].z = ((char*)(the_bmp->pixels))[index++];
+                    pixels_[(y * width + x)].y = ((char*)(the_bmp->pixels))[index++];
+                    pixels_[(y * width + x)].x = ((char*)(the_bmp->pixels))[index++];
                 }
             }
 
@@ -308,13 +185,10 @@ SDKBitMap::load(const char * filename)
             }
         }
 
-        // Loaded file so we can close the file.
-        fclose(fd);
-        delete[] tmpPixels;
-
         // Loaded file so record this fact
         isLoaded_  = true;
     }
+    SDL_FreeSurface(the_bmp);
 }
 
 int
@@ -335,81 +209,6 @@ SDKBitMap::colorIndex(uchar4 color)
 bool
 SDKBitMap::write(const char * filename)
 {
-    if (!isLoaded_) {
-        return false;
-    }
-
-    // Open BMP file
-    FILE * fd = fopen(filename, "wb");
-    //FILE * fd;
-    //fopen_s(&fd, filename, "wb");
-
-
-    // Opened OK
-    if (fd != NULL) {
-        // Write header
-        fwrite((BitMapHeader *)this, sizeof(BitMapHeader), 1, fd);
-
-        // Failed to write header
-        if (ferror(fd)) {
-            fclose(fd);
-            return false;
-        }
-
-        // Write map info header
-        fwrite((BitMapInfoHeader *)this, sizeof(BitMapInfoHeader), 1, fd);
-
-        // Failed to write map info header
-        if (ferror(fd)) {
-            fclose(fd);
-            return false;
-        }
-
-        // Write palate for 8 bits per pixel
-        if(bitsPerPixel == 8) {
-            fwrite(
-                (char *)colors_,
-                numColors_ * sizeof(ColorPalette),
-                1,
-                fd);
-
-            // Failed to write colors
-            if (ferror(fd)) {
-                fclose(fd);
-                return false;
-            }
-        }
-
-        for(int y = 0; y < height; y++) {
-            for(int x = 0; x < width; x++) {
-                // Read RGB values
-                if (bitsPerPixel == 8) {
-                    fputc(
-                        colorIndex(
-                            pixels_[(y * width + x)]),
-                            fd);
-                }
-                else { // 24 bit
-                    fputc(pixels_[(y * width + x)].z, fd);
-                    fputc(pixels_[(y * width + x)].y, fd);
-                    fputc(pixels_[(y * width + x)].x, fd);
-
-                    if (ferror(fd)) {
-                        fclose(fd);
-                        return false;
-                    }
-                }
-            }
-
-            // Add padding
-            for(int x = 0; x < (4 - (3 * width) % 4) % 4; x++) {
-                fputc(0, fd);
-            }
-        }
-
-        return true;
-    }
-
-    return false;
+	return write( filename, width, height, (unsigned int*)pixels_);
 }
 } //streamsdk
diff --git a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cl/app/Makefile b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cl/app/Makefile
index e713bc5..60fcd6a 100755
--- a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cl/app/Makefile
+++ b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cl/app/Makefile
@@ -40,8 +40,6 @@ SUBDIRS = AESEncryptDecrypt\
 	  DeviceFission \
 	  LUDecomposition \
 	  BlackScholesDP \
-	  BufferBandwidth \
-	  ImageBandwidth \
 	  TransferOverlap \
 	  AtomicCounters \
 	  BinomialOptionMultiGPU \
@@ -54,6 +52,11 @@ SUBDIRS = AESEncryptDecrypt\
 	  AdvancedMultiGPU \
 	  MemoryModel
 
+#these tests are programmed with intel intrinsics
+ifeq ($(ISINTEL), "true")
+SUBDIRS += BufferBandwidth \
+	   ImageBandwidth 
+endif
 
 ifneq ($(OS), lnx)
 SUBDIRS += SimpleDX10 SimpleDX11 OpenCLService
diff --git a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cpp_cl/app/IntroStaticCPPKernel/IntroStaticCPPKernel.cpp b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cpp_cl/app/IntroStaticCPPKernel/IntroStaticCPPKernel.cpp
index d310168..32358da 100755
--- a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cpp_cl/app/IntroStaticCPPKernel/IntroStaticCPPKernel.cpp
+++ b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cpp_cl/app/IntroStaticCPPKernel/IntroStaticCPPKernel.cpp
@@ -20,6 +20,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 #include <iostream>
 #include <fstream>
 #include <string>
+#include <cstdlib>
 
 
 using namespace cl;
--- a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cl/app/Mandelbrot/Mandelbrot_Kernels.cl
+++ b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cl/app/Mandelbrot/Mandelbrot_Kernels.cl
@@ -258,8 +258,6 @@
     mandelbrotImage[4 * tid + 3] = color[3];
 }
 
-#define native_log2 log2
-#define native_cos  cos
 
 #ifdef ENABLE_DOUBLE
 #ifdef KHR_DP_EXTENSION

--- a/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cl/app/DeviceFission/DeviceFission.cpp
+++ b/AMD-APP-SDK-v2.8-RC-lnx64/samples/opencl/cl/app/DeviceFission/DeviceFission.cpp
@@ -94,7 +94,7 @@
 	{
 		retValue = deviceInfo.setDeviceInfo(Devices[i]);
 		CHECK_ERROR(retValue, 0, "SDKDeviceInfo::setDeviceInfo() failed");
-		if (deviceInfo.dType == CL_DEVICE_TYPE_CPU)
+		if (deviceInfo.dType & CL_DEVICE_TYPE_CPU)
 		{
 			cpuDevice = Devices[i];
 		}
@@ -131,6 +131,14 @@
 	status = clCreateSubDevices(cpuDevice, partitionPrty, numSubDevices, subDevices, NULL);
 	CHECK_OPENCL_ERROR( status, "clCreateSubDevices failed.");
 
+    // recreate the context with the subdevices
+    status = clReleaseContext(rContext);
+    CHECK_OPENCL_ERROR( status, "clReleaseContext failed.");
+
+    rContext = clCreateContext(platform ? cps : NULL,
+	    numSubDevices, subDevices, NULL, NULL, &status);
+    CHECK_OPENCL_ERROR( status, "clCreateContext failed.");
+
     return SDK_SUCCESS;
 }