1 // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC. 2 // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 3 // All Rights 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 #include "ceed-magma.h" 18 19 static int CeedInit_Magma_Det(const char *resource, Ceed ceed) { 20 int ierr; 21 if (strcmp(resource, "/gpu/cuda/magma/det") 22 && strcmp(resource, "/gpu/hip/magma/det")) 23 // LCOV_EXCL_START 24 return CeedError(ceed, 1, "Magma backend cannot use resource: %s", resource); 25 // LCOV_EXCL_STOP 26 ierr = CeedSetDeterministic(ceed, true); CeedChk(ierr); 27 28 // Create reference CEED that implementation will be dispatched 29 // through unless overridden 30 Ceed ceedref; 31 #ifdef HAVE_HIP 32 CeedInit("/gpu/hip/magma", &ceedref); 33 #else 34 CeedInit("/gpu/cuda/magma", &ceedref); 35 #endif 36 ierr = CeedSetDelegate(ceed, ceedref); CeedChk(ierr); 37 38 // Create reference CEED for restriction 39 Ceed restrictionceedref; 40 #ifdef HAVE_HIP 41 CeedInit("/gpu/hip/ref", &restrictionceedref); 42 #else 43 CeedInit("/gpu/cuda/ref", &restrictionceedref); 44 #endif 45 ierr = CeedSetObjectDelegate(ceed, restrictionceedref, "ElemRestriction"); 46 CeedChk(ierr); 47 48 return 0; 49 } 50 51 __attribute__((constructor)) 52 static void Register(void) { 53 #ifdef HAVE_HIP 54 CeedRegister("/gpu/hip/magma/det", CeedInit_Magma_Det, 125); 55 #else 56 CeedRegister("/gpu/cuda/magma/det", CeedInit_Magma_Det, 125); 57 #endif 58 } 59