mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-03 10:06:09 +01:00
Fix preprocessor else and remove old cuBLAS interface
This commit is contained in:
parent
eb71a752f5
commit
0ce0a93522
@ -2288,98 +2288,6 @@ qmckl_transpose (qmckl_context context,
|
|||||||
|
|
||||||
#+end_src
|
#+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:
|
* End of files :noexport:
|
||||||
|
|
||||||
|
|
||||||
|
@ -4903,7 +4903,7 @@ qmckl_exit_code qmckl_provide_tmp_c(qmckl_context context)
|
|||||||
ctx->jastrow.een_rescaled_e,
|
ctx->jastrow.een_rescaled_e,
|
||||||
ctx->jastrow.een_rescaled_n,
|
ctx->jastrow.een_rescaled_n,
|
||||||
ctx->jastrow.tmp_c);
|
ctx->jastrow.tmp_c);
|
||||||
#elif
|
#else
|
||||||
rc = qmckl_compute_tmp_c(context,
|
rc = qmckl_compute_tmp_c(context,
|
||||||
ctx->jastrow.cord_num,
|
ctx->jastrow.cord_num,
|
||||||
ctx->electron.num,
|
ctx->electron.num,
|
||||||
@ -4926,7 +4926,7 @@ qmckl_exit_code qmckl_provide_tmp_c(qmckl_context context)
|
|||||||
ctx->jastrow.een_rescaled_e,
|
ctx->jastrow.een_rescaled_e,
|
||||||
ctx->jastrow.een_rescaled_n,
|
ctx->jastrow.een_rescaled_n,
|
||||||
ctx->jastrow.tmp_c);
|
ctx->jastrow.tmp_c);
|
||||||
#elif
|
#else
|
||||||
rc = qmckl_compute_tmp_c(context,
|
rc = qmckl_compute_tmp_c(context,
|
||||||
ctx->jastrow.cord_num,
|
ctx->jastrow.cord_num,
|
||||||
ctx->electron.num,
|
ctx->electron.num,
|
||||||
@ -4999,7 +4999,7 @@ qmckl_exit_code qmckl_provide_dtmp_c(qmckl_context context)
|
|||||||
ctx->jastrow.een_rescaled_e_deriv_e,
|
ctx->jastrow.een_rescaled_e_deriv_e,
|
||||||
ctx->jastrow.een_rescaled_n,
|
ctx->jastrow.een_rescaled_n,
|
||||||
ctx->jastrow.dtmp_c);
|
ctx->jastrow.dtmp_c);
|
||||||
#elif
|
#else
|
||||||
rc = qmckl_compute_dtmp_c(context,
|
rc = qmckl_compute_dtmp_c(context,
|
||||||
ctx->jastrow.cord_num,
|
ctx->jastrow.cord_num,
|
||||||
ctx->electron.num,
|
ctx->electron.num,
|
||||||
@ -5020,7 +5020,7 @@ qmckl_exit_code qmckl_provide_dtmp_c(qmckl_context context)
|
|||||||
ctx->jastrow.een_rescaled_e_deriv_e,
|
ctx->jastrow.een_rescaled_e_deriv_e,
|
||||||
ctx->jastrow.een_rescaled_n,
|
ctx->jastrow.een_rescaled_n,
|
||||||
ctx->jastrow.dtmp_c);
|
ctx->jastrow.dtmp_c);
|
||||||
#elif
|
#else
|
||||||
rc = qmckl_compute_dtmp_c(context,
|
rc = qmckl_compute_dtmp_c(context,
|
||||||
ctx->jastrow.cord_num,
|
ctx->jastrow.cord_num,
|
||||||
ctx->electron.num,
|
ctx->electron.num,
|
||||||
|
Loading…
Reference in New Issue
Block a user