"Fossies" - the Fresh Open Source Software Archive

Member "pocl-1.8/examples/AMD/AMDSDK.patch" (12 Oct 2021, 15847 Bytes) of package /linux/misc/pocl-1.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Diff source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

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