I have been able to statically compile my code, however I've notice the following:
1 - If the code is dynamically compiled to MKL , then both magmablas_dgemm and magma_dpotrf_gpu-magma_dpotri_gpu works fine.
2 - If the code is statically compiled to MKL:
2.1 - magmablas_dgemm works fine
2.2 - magma_dpotrf_gpu-magma_dpotri_gpu gives a sgementation fault
I have made a very simple example case using magma testing examples
Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <cublas.h>
#include <cublas_v2.h>
#include "flops.h"
#include "magma.h"
#include "magma_lapack.h"
#include "testings.h"
int main( int argc, char** argv)
{
//TESTING_CUDA_INIT();
FILE *fp;
magma_timestr_t start, end;
magma_int_t i,j,k;
float flops, magma_perf, cuda_perf, error, work[1];
char transA;
char transB;
magma_int_t M, M0 = 0;
magma_int_t N, N0 = 0;
magma_int_t K, K0 = 0;
const char *uplo = MagmaLowerStr;
magma_int_t info;
float alpha = 1.0f;
float beta = 0.0f;
// float *h_A, *h_B, *h_C;
double *h_C;
double *d_A, *d_B, *d_C;
float c_neg_one = MAGMA_S_NEG_ONE;
transA = MagmaTrans;
transB = MagmaNoTrans;
// A[MxK]
M = 3;
K = 1;
//B [KxN]
N = 4;
//C [MxN]
TESTING_MALLOC( h_C, double, M*N );
TESTING_DEVALLOC( d_A, double, M*K );
TESTING_DEVALLOC( d_B, double, K*N );
TESTING_DEVALLOC( d_C, double, M*N );
double h_A[3] = {-0.222225,0.05397, 0.456780};
double h_B[4] = {0.340188, -0.105617, 0.283099, 0.29844};
for (i = 0; i < M; i++)
for (j = 0; j < K; j++){
printf("A[%d] = %g\n",i*K+j,h_A[i*K+j] );
}
printf("\n");
for (i = 0; i < K; i++)
for (j = 0; j< N; j++){
printf("B[%d] = %g\n",i*N+j, h_B[i*N+j] );
}
cudaMemcpy(d_A, h_A, M*K*sizeof(double),cudaMemcpyHostToDevice);
cudaMemcpy(d_B, h_B, K*N*sizeof(double),cudaMemcpyHostToDevice);
//h_A[MxK]
int lda = K;
// h_B[KxN]
int ldb = K;
// h_C[MxN]
int ldc = M;
magmablas_dgemm( transA, transB, M, N, K, alpha, d_A, lda,
d_B, ldb, beta, d_C, ldc);
magma_dgetmatrix( M, N, d_C, M, h_C, M );
printf("\n");
for (i = 0; i< M;i++)
for (j = 0; j < N;j++)
printf("C[%d] = %g\n",i*N+j,h_C[i*N+j] );
magma_dpotrf_gpu(uplo[0], 2, d_B, 2, &info);
if (info != 0)
printf("Argument %d of magma_dpotrf had an illegal value.\n", (int) -info);
magma_dpotri_gpu(uplo[0], 2, d_B, 2, &info);
if (info != 0)
printf("Argument %d of magma_dpotri had an illegal value.\n", (int) -info);
magma_dgetmatrix( 2, 2, d_B, 2, h_B, 2 );
for (i = 0; i< 2;i++)
for (j = 0; j < 2;j++)
printf("B_inv[%d] = %g\n",i*2+j,h_B[i*2+j] );
TESTING_FREE( h_C );
TESTING_DEVFREE( d_A );
TESTING_DEVFREE( d_C );
TESTING_DEVFREE( d_B );
TESTING_CUDA_FINALIZE();
}
The make.inc file used to statically compile this file
Code: Select all
#//////////////////////////////////////////////////////////////////////////////
# -- MAGMA (version 1.2.1) --
# Univ. of Tennessee, Knoxville
# Univ. of California, Berkeley
# Univ. of Colorado, Denver
# June 2012
#//////////////////////////////////////////////////////////////////////////////
# 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)
# See http://developer.nvidia.com/cuda-gpus
GPU_TARGET = Fermi
CC = g++
NVCC = nvcc
FORT = gfortran
ARCH = ar
ARCHFLAGS = cr
RANLIB = ranlib
OPTS = -O3 -DADD_ -fopenmp -DUNIX -w -DMKL_ILP64 -m64 -I$(MKLROOT)/include
F77OPTS = -O3 -DADD_ -fdefault-integer-8
FOPTS = -O3 -DADD_ -x f95-cpp-input -fdefault-integer-8
NVOPTS = -O3 -DADD_ -Xcompiler -fopenmp -lgomp --compiler-options -fno-strict-aliasing -DUNIX -Xptxas="-v"
LDOPTS = -fPIC
# Multi-threaded version
LIB = -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_ilp64.a $(MKLROOT)/lib/intel64/libmkl_gnu_thread.a $(MKLROOT)/lib/intel64/libmkl_core.a -Wl,--end-group -ldl -lpthread -lm -lcublas -lcudart
CUDADIR = /usr/local/cuda
LIBDIR = -L /opt/intel/mkl/lib/intel64 \
-L$(CUDADIR)/lib64
INC = -I$(CUDADIR)/include
Am I missing something trivial here?