Build problems with clmagma-0.2.0

Open discussion for MAGMA

Build problems with clmagma-0.2.0

Postby marin » Fri Jun 01, 2012 1:26 am

Hi,

I am trying to build clmagma-0.2.0 on a system running an AMD A8-3850 APU with Radeon(tm) HD Graphics. I have installed

    clAmdBlas-1.8.269
    AMD-APP-SDK-v2.6

The clmagma makefile runs through and everything builds but most of the opencl code. The makefile output:

Code: Select all
gcc -fPIC -Xlinker -zmuldefs -Wl,-rpath=/opt/gcc-4.6.0/lib64 clcompile.o -o clcompile \
        -L../lib -lclmagma -L/opt/clAmdBlas-1.8.269/lib64 -L/opt/gcc-4.6.0/lib64 -L/opt/acml5.1.0/gfortran64_mp/lib -lacml_mp -lclAmdBlas -lOpenCL
./clcompile sinplace_transpose.cl
Initializing...
Device: BeaverCreek
./clcompile spermute-v2.cl
Initializing...
Device: BeaverCreek
clBuildProgram error at 565 in CL_MAGMA_RT.cpp
clBuildProgram error code: -11
...


The error code is actually not in CL_MAGMA_RT.cpp. I had added

Code: Select all
    562         ciErrNum = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);
    563         if (ciErrNum != CL_SUCCESS)
    564         {
    565                 printf ("clBuildProgram error at %d in %s\n", __LINE__, __FILE__);
+    566                 printf ("clBuildProgram error code: %d\n", ciErrNum);
    567                 return false;
    568         }


Unfortunately this error code is pretty generic. The opencl spec states

CL_BUILD_PROGRAM_FAILURE if there is a failure to build the program executable. This error will be returned if clBuildProgram does not return until the build has completed.


Three builds succeed:

Code: Select all
[root@apudemo clmagma-0.2.0]# locate *.co
/root/clmagma-0.2.0/interface_opencl/cpermute-v2.co
/root/clmagma-0.2.0/interface_opencl/sinplace_transpose.co
/root/clmagma-0.2.0/interface_opencl/stranspose-v2.co


The build of all others generates

clBuildProgram error code: -11

Any idea anybody what could be the issue?

Thank you very much in advance
marin
 
Posts: 3
Joined: Fri Jun 01, 2012 12:37 am

Re: Build problems with clmagma-0.2.0

Postby marin » Wed Jun 13, 2012 9:46 pm

Just for reference ... a colleague helped solve the problem ...

1. The build of the single precision code bits failed due to a bug in clmagma 0.2 beta. In CL_MAGMA_RT.cpp:

Code: Select all
549         fileStrings = fileToString(FileName);


calling

Code: Select all
string CL_MAGMA_RT::fileToString(const char* filename)
{
        ifstream fileStream(filename, ios::binary | ios::in | ios::ate);

        if(fileStream.is_open() == true)
        {
                size_t fileSize = fileStream.tellg();

                char * cbuffer = new char[fileSize];

                fileStream.seekg(0, ios::beg);
                fileStream.read(cbuffer, fileSize);

                string  memoryBuffer(cbuffer);
                delete [] cbuffer;
                return memoryBuffer;
        }


cbuffer is not explicitly null terminated and the string class constructor does not 'know' the length of the string in cbuffer. The options we found to work are either to change

Code: Select all
string  memoryBuffer(cbuffer);


to

Code: Select all
string  memoryBuffer(cbuffer, fileSize);


or to explicitly null terminate cbuffer so that

Code: Select all
char * cbuffer = new char[fileSize];


is modified to

Code: Select all
char * cbuffer = new char[fileSize + 1];


and

Code: Select all
cbuffer[fileSize] = '\0'


The other issue is that Llano based APUs don't support double precision operations. Therefore only the single precision code will built. We got this to work switching to Trinity (A10-5800K) but had to add pragmas with AMD OpenCL extensions to the opencl code such as in dtranspose.cl

Code: Select all
11 //#include "common_magma.h"
12 //#include "commonblas.h"
13
14 #pragma OPENCL EXTENSION cl_amd_fp64 : enable
marin
 
Posts: 3
Joined: Fri Jun 01, 2012 12:37 am


Return to User discussion

Who is online

Users browsing this forum: No registered users and 3 guests