   int liwork;
   magma_ssyevd_gpu(jobz, uplo, n, input_data, lda, w, wA, n, &lwork, -1, &liwork, -1, &info);
 
-  float *work = th_magma_smalloc_pinned((size_t)lwork);
-  int *iwork = th_magma_imalloc_pinned(liwork);
+  float *work = th_magma_malloc_pinned<float>((size_t)lwork);
+  int *iwork = th_magma_malloc_pinned<int>(liwork);
 
   // compute eigenvalues and, optionally, eigenvectors
   magma_ssyevd_gpu(jobz, uplo, n, input_data, lda, w, wA, n, work, (int) lwork, iwork, liwork, &info);

}

#ifdef USE_MAGMA
static inline float* th_magma_smalloc_pinned(size_t n)
{
  float* ptr;
  if (MAGMA_SUCCESS != magma_smalloc_pinned(&ptr, n))
    THError("$ Torch: not enough memory: you tried to allocate %dGB. Buy new RAM!", n/268435456);
  return ptr;
}

static inline int* th_magma_imalloc_pinned(size_t n)
{
  int* ptr;
  if (MAGMA_SUCCESS != magma_imalloc_pinned(&ptr, n))
    THError("$ Torch: not enough memory: you tried to allocate %dGB. Buy new RAM!", n/268435456);
  return ptr;
}

static void THCudaTensor_copyArray1d(THCState *state, THCudaTensor *self, float *src, int k)

  float *a_data = THCudaTensor_data(state, a);
  float *b_data = THCudaTensor_data(state, b);

  int *ipiv = th_magma_malloc_pinned<int>(n);

  int info;
  magma_sgesv_gpu(n, nrhs, a_data, n, ipiv, b_data, n, &info);
