Running executable file, compiled with magma, in other machi

Open discussion for MAGMA

Running executable file, compiled with magma, in other machi

Postby luiceur » Wed Mar 13, 2013 11:44 am

Hi,

We are trying to run an executable file succesfully compiled with magma. However, if the target machine does not have MKL loaded or installed, I've got shared libraries errors:
error while loading shared libraries: libmkl_intel_lp64.so: cannot open shared object file: No such file or directory

Is there a way to compile magma or the application that uses magma to be able to just copy the executable to another machine, which it does not have MKL or magma installed, and run it?
luiceur
 
Posts: 26
Joined: Tue Jul 10, 2012 4:38 am

Re: Running executable file, compiled with magma, in other m

Postby mgates3 » Wed Mar 13, 2013 3:33 pm

In the current Makefiles, magma is typically compiled as a static library, so it should be copied into your application when linked. The BLAS and LAPACK libraries from MKL are typically shared libraries, so they need to be resident on the machine where the application is located. Alternatively, you can statically link the MKL libraries. See the MKL link advisor for how to do this:

http://software.intel.com/sites/products/mkl/

That MKL link line would replace the relevant parts of LIB in the make.inc file, leaving of course -lcublas and -lcudart.

-mark
mgates3
 
Posts: 388
Joined: Fri Jan 06, 2012 2:13 pm

Re: Running executable file, compiled with magma, in other m

Postby luiceur » Thu Mar 14, 2013 3:58 pm

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?
luiceur
 
Posts: 26
Joined: Tue Jul 10, 2012 4:38 am

Re: Running executable file, compiled with magma, in other m

Postby mgates3 » Fri Mar 15, 2013 3:53 pm

You probably want _lp64 libraries, not _ilp64. lp64 has 32-bit int, while ilp64 has 64-bit int. Both have 64-bit long and pointer. Unless you changed the magma_int_t to long, it should be a 32-bit int.

If there are still problems, you may want to try using libmkl_gf_lp64.a instead of libmkl_intel_lp64.a. The gf version is for gfortran, the other Intel. I don't know if this will make a difference or not.

-mark
mgates3
 
Posts: 388
Joined: Fri Jan 06, 2012 2:13 pm


Return to User discussion

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

cron