mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-03 10:06:09 +01:00
Cleanup before merging into QMCkl's GPU branch
This commit is contained in:
parent
1173bb2586
commit
84013a5f76
@ -2288,6 +2288,98 @@ qmckl_transpose (qmckl_context context,
|
||||
|
||||
#+end_src
|
||||
|
||||
* cuBLAS interface (optional)
|
||||
We propose a cuBLAS version of some QMCkl kernels. However, because cuBLAS is written in C, we need to define a Fortran interface for it. We start by defining functions to manage the cuBLAS handle structure from Fortran, before writing interfaces for the specific cuBLAS functions we are interested in.
|
||||
|
||||
TODO These are the C functions that are supposed to be called from Fortran. We still need to write the interfaces themselves.
|
||||
|
||||
#+begin_src c :tangle (eval h_private_func) :comments org
|
||||
#ifdef HAVE_CUBLAS_OFFLOAD
|
||||
#include <cublas_v2.h>
|
||||
#endif
|
||||
#+end_src
|
||||
|
||||
#+begin_src c :tangle (eval h_private_func) :comments org
|
||||
#ifdef HAVE_CUBLAS_OFFLOAD
|
||||
cublasHandle_t* get_cublas_handle_interfaced();
|
||||
#endif
|
||||
#+end_src
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :exports none
|
||||
#ifdef HAVE_CUBLAS_OFFLOAD
|
||||
cublasHandle_t* get_cublas_handle_interfaced() {
|
||||
cublasHandle_t* handle = malloc(sizeof(cublasHandle_t));
|
||||
|
||||
cublasStatus_t status = cublasCreate(handle);
|
||||
if (status != CUBLAS_STATUS_SUCCESS){
|
||||
fprintf(stderr, "Error while initializing cuBLAS\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
#endif
|
||||
#+end_src
|
||||
|
||||
#+begin_src c :tangle (eval h_private_func) :comments org
|
||||
#ifdef HAVE_CUBLAS_OFFLOAD
|
||||
void destroy_cublas_handle_interfaced(cublasHandle_t* handle);
|
||||
#endif
|
||||
#+end_src
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :exports none
|
||||
#ifdef HAVE_CUBLAS_OFFLOAD
|
||||
void destroy_cublas_handle_interfaced(cublasHandle_t* handle) {
|
||||
if(handle != NULL) {
|
||||
free(handle);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#+end_src
|
||||
|
||||
** DGEMM
|
||||
|
||||
#+begin_src c :tangle (eval h_private_func) :comments org
|
||||
#ifdef HAVE_CUBLAS_OFFLOAD
|
||||
cublasStatus_t cublasDgemm_f(
|
||||
cublasHandle_t* handle,
|
||||
cublasOperation_t* transa, cublasOperation_t* transb,
|
||||
int* m, int* n, int* k,
|
||||
const double* alpha,
|
||||
const double*A, int* lda,
|
||||
const double* B, int* ldb,
|
||||
const double* beta,
|
||||
double*C, int* ldc
|
||||
);
|
||||
#endif
|
||||
#+end_src
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :exports none
|
||||
|
||||
#ifdef HAVE_CUBLAS_OFFLOAD
|
||||
cublasStatus_t cublasDgemm_f(
|
||||
cublasHandle_t* handle,
|
||||
cublasOperation_t* transa, cublasOperation_t* transb,
|
||||
int* m, int* n, int* k,
|
||||
const double* alpha,
|
||||
const double*A, int* lda,
|
||||
const double* B, int* ldb,
|
||||
const double* beta,
|
||||
double*C, int* ldc
|
||||
) {
|
||||
return cublasDgemm_f(
|
||||
handle,
|
||||
transa, transb,
|
||||
m, n, k,
|
||||
alpha, A, lda, B,ldb,
|
||||
beta, C, ldc
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
* End of files :noexport:
|
||||
|
||||
|
||||
|
@ -5592,7 +5592,7 @@ integer function qmckl_compute_tmp_c_cublas_offload_f(context, cord_num, elec_nu
|
||||
LDB = size(een_rescaled_n,1)
|
||||
LDC = size(tmp_c,1)
|
||||
|
||||
! Alloc and copy memory on device
|
||||
! TODO Replace with calls to cuBLAS
|
||||
|
||||
do nw=1, walk_num
|
||||
do i=0, cord_num-1
|
||||
|
Loading…
Reference in New Issue
Block a user