I have a new intel xeon Ubuntu 12.04 server with 2 Tahiti 7970 AMD graphics card on which I'd like to use clmagma and in particular the dgetrf function.
I had no problem to compile clmagma with clAmdblas and ATLAS. Here is my make.inc in case that's of any use:
Code: Select all
#//////////////////////////////////////////////////////////////////////////////
# -- MAGMA (version 1.0.0) --
# Univ. of Tennessee, Knoxville
# Univ. of California, Berkeley
# Univ. of Colorado, Denver
# April 2012
#//////////////////////////////////////////////////////////////////////////////
prefix = /home/seb/local
#
# GPU_TARGET specifies for which GPU you want to compile MAGMA:
# "Tesla" (NVIDIA compute capability 1.x cards)
# "Fermi" (NVIDIA compute capability 2.x cards)
# "AMD" (clMAGMA with AMD cards)
# See http://developer.nvidia.com/cuda-gpus
GPU_TARGET = AMD
CC = g++
NVCC = nvcc
FORT = gfortran
ARCH = ar
ARCHFLAGS = cr
RANLIB = ranlib
OPTS = -O0 -DADD_
F77OPTS = -O3 -DADD_
FOPTS = -O3 -DADD_ -x f95-cpp-input
NVOPTS = -O3 -DADD_ --compiler-options -fno-strict-aliasing -DUNIX
LDOPTS = -fPIC -Xlinker -zmuldefs
LIB = -llapack -lf77blas -latlas -lcblas -lpthread -ldl -lclAmdBlas -lOpenCL -lgfortran -lm
GPUBLAS = /opt/clAmdBlas-1.10.321
LIBDIR = -L/home/seb/local/lib -L/opt/AMDAPP/lib/x86_64 -L$(GPUBLAS)/lib64
INC = -I/home/seb/include -I$(GPUBLAS)/include -I/opt/AMDAPP/include
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <magma.h>
int main(void) {
double * A;
magmaDouble_ptr dA;
magma_int_t * ipiv = malloc (3*sizeof (int));
magma_queue_t queue;
magma_device_t device;
magma_int_t info;
int num;
magma_init ();
if ( MAGMA_SUCCESS == magma_get_devices (&device, 2, &num ) )
fprintf( stderr, "magma_get_devices found %i GPU\n", num);
if ( MAGMA_SUCCESS == magma_queue_create( device, &queue ) )
fprintf( stderr, "queue created \n");
// Allocate and fill matrix
magma_malloc_host((void**) &A, 9*sizeof(double));
*(A) = 2.; *(A+1) = -1.; *(A+2) = 0.;
*(A+3) = -1.; *(A+4) = 2.;*(A+5) = -1.;
*(A+6) = 0.; *(A+7) = -1.; *(A+8) = 2.;
// Copy matrix on GPU
if ( MAGMA_SUCCESS == magma_malloc((magma_ptr *) &dA,
(3*3) * sizeof (double)) )
fprintf (stderr, "malloc is a success\n");
if ( MAGMA_SUCCESS == magma_dsetmatrix( 3, 3, A, 0, 3, dA, 0, 3, queue) )
fprintf (stderr, "dsetmatrix is a success\n");
// Get LU decomposition
magma_dgetrf_gpu ( 3, 3, dA, 0, 3, ipiv, &info, queue);
if ( info == MAGMA_SUCCESS)
fprintf (stderr, "DGETRF is a success\n");
else
exit(-1);
// Retrieve and print result
if ( MAGMA_SUCCESS == magma_dgetmatrix( 3, 3, dA, 0, 3, A, 0, 3, queue))
fprintf (stderr, "dsetmatrix is a success\n");
fprintf(stdout, "%f %f %f \n %f %f %f\n %f %f %f \n",
*A, *(A+1), *(A+2),
*(A+3), *(A+4), *(A+5),
*(A+6), *(A+7), *(A+8));
// Free structures
magma_free (dA);
magma_free_host (A);
free (ipiv);
magma_queue_destroy (queue);
magma_finalize ();
return 0;
}
gcc -c -I/opt/AMDAPP/include -I/home/seb/local/include magma_test.c -o magma_test.o
gcc magma_test.o -o magma_test.exe -L/opt/AMDAPP/lib/x86_64/ -L/home/seb/local/lib `pkg-config --cflags --libs magma`
which seems to work fine.
When I run the program, the initialisation stage works fine, but magma_dsetmatrix leads to the code crashing due to a "segmentation fault"
Here is what I get from gdb:
Program terminated with signal 11, Segmentation fault.
#0 0x00007f6629091bbb in clEnqueueWriteBufferRect ()
from /opt/AMDAPP/lib/x86_64/libOpenCL.so.1
(gdb) up
#1 0x0000000000413dfb in magma_dsetmatrix ()
The strange thing is that if I replace magma_dsetmatrix by the equivalent clEnqueueWriteBufferRect command, the code does not crash and performs the LU decomposition properly. Also, testing_dgetrf_gpu on my system runs very slow, and the GPU hardly seems to be faster than the CPUs. Independently, I have run a program called FlopsCL to assess the speed of my GPU as it is installed and it seems to show that the GPU performs normally (around 1000 GFlops in double precision).
Any help would be appreciated.