1 // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2 // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3 // reserved. See files LICENSE and NOTICE for details. 4 // 5 // This file is part of CEED, a collection of benchmarks, miniapps, software 6 // libraries and APIs for efficient high-order finite element and spectral 7 // element discretizations for exascale applications. For more information and 8 // source code availability see http://github.com/ceed. 9 // 10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11 // a collaborative effort of two U.S. Department of Energy organizations (Office 12 // of Science and the National Nuclear Security Administration) responsible for 13 // the planning and preparation of a capable exascale ecosystem, including 14 // software, applications, hardware, advanced system engineering and early 15 // testbed platforms, in support of the nation's exascale computing imperative. 16 17 // magma functions specific to ceed 18 19 #include <string.h> 20 #include <ceed-backend.h> 21 #include "magma.h" 22 23 typedef struct { 24 CeedScalar *dqref1d; 25 CeedScalar *dinterp1d; 26 CeedScalar *dgrad1d; 27 CeedScalar *dqweight1d; 28 } CeedBasis_Magma; 29 30 typedef struct { 31 const CeedScalar **inputs; 32 CeedScalar **outputs; 33 bool setupdone; 34 } CeedQFunction_Magma; 35 36 #define USE_MAGMA_BATCH 37 #define USE_MAGMA_BATCH2 38 #define USE_MAGMA_BATCH3 39 #define USE_MAGMA_BATCH4 40 41 CEED_INTERN void magma_dtensor_contract(Ceed ceed, CeedInt A, CeedInt B, 42 CeedInt C, CeedInt J, 43 const CeedScalar *t, 44 CeedTransposeMode tmode, 45 const CeedInt Add, const CeedScalar *u, 46 CeedScalar *v); 47 48 #ifdef __cplusplus 49 CEED_INTERN { 50 #endif 51 void magmablas_dbasis_apply_batched_eval_interp(magma_int_t P, magma_int_t Q, 52 magma_int_t dim, magma_int_t ncomp, const double *dT, CeedTransposeMode tmode, 53 const double *dU, magma_int_t ustride, double *dV, magma_int_t vstride, 54 magma_int_t batchCount); 55 56 void magmablas_dbasis_apply_batched_eval_grad(magma_int_t P, magma_int_t Q, 57 magma_int_t dim, magma_int_t ncomp, magma_int_t nqpt, const double* dinterp1d, 58 const double *dgrad1d, CeedTransposeMode tmode, const double *dU, 59 magma_int_t ustride, double *dV, magma_int_t vstride, magma_int_t batchCount, 60 magma_int_t dim_ctr); 61 62 void magmablas_dbasis_apply_batched_eval_weight(magma_int_t Q, magma_int_t dim, 63 const double *dqweight1d, double *dV, magma_int_t vstride, 64 magma_int_t batchCount); 65 66 magma_int_t 67 magma_isdevptr(const void *A); 68 69 CEED_INTERN int CeedBasisCreateTensorH1_Magma(CeedInt dim, CeedInt P1d, 70 CeedInt Q1d, const CeedScalar *interp1d, const CeedScalar *grad1d, 71 const CeedScalar *qref1d, const CeedScalar *qweight1d, CeedBasis basis); 72 73 CEED_INTERN int CeedBasisCreateH1_Magma(CeedElemTopology topo, CeedInt dim, 74 CeedInt ndof, CeedInt nqpts, const CeedScalar *interp, const CeedScalar *grad, 75 const CeedScalar *qref, const CeedScalar *qweight, CeedBasis basis); 76 77 #ifdef __cplusplus 78 } 79 #endif 80 81 #define CeedDebug(...) 82 //#define CeedDebug(format, ...) fprintf(stderr, format, ## __VA_ARGS__) 83 84 // comment the line below to use the default magma_is_devptr function 85 #define magma_is_devptr magma_isdevptr 86 87 // batch stride, override using -DMAGMA_BATCH_STRIDE=<desired-value> 88 #ifndef MAGMA_BATCH_STRIDE 89 #define MAGMA_BATCH_STRIDE (1000) 90 #endif 91