1cb23e90cSJeremy L Thompson // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC. 2cb23e90cSJeremy L Thompson // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 3cb23e90cSJeremy L Thompson // All Rights reserved. See files LICENSE and NOTICE for details. 4cb23e90cSJeremy L Thompson // 5cb23e90cSJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software 6cb23e90cSJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral 7cb23e90cSJeremy L Thompson // element discretizations for exascale applications. For more information and 8cb23e90cSJeremy L Thompson // source code availability see http://github.com/ceed. 9cb23e90cSJeremy L Thompson // 10cb23e90cSJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11cb23e90cSJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office 12cb23e90cSJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for 13cb23e90cSJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including 14cb23e90cSJeremy L Thompson // software, applications, hardware, advanced system engineering and early 15cb23e90cSJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative. 16cb23e90cSJeremy L Thompson 17cb23e90cSJeremy L Thompson #include "ceed-magma.h" 18cb23e90cSJeremy L Thompson 19cb23e90cSJeremy L Thompson static int CeedInit_Magma_Det(const char *resource, Ceed ceed) { 20cb23e90cSJeremy L Thompson int ierr; 21*40461fa4Snbeams if (strcmp(resource, "/gpu/cuda/magma/det") 22*40461fa4Snbeams && strcmp(resource, "/gpu/hip/magma/det")) 23cb23e90cSJeremy L Thompson // LCOV_EXCL_START 24cb23e90cSJeremy L Thompson return CeedError(ceed, 1, "Magma backend cannot use resource: %s", resource); 25cb23e90cSJeremy L Thompson // LCOV_EXCL_STOP 26cb23e90cSJeremy L Thompson ierr = CeedSetDeterministic(ceed, true); CeedChk(ierr); 27cb23e90cSJeremy L Thompson 28cb23e90cSJeremy L Thompson // Create reference CEED that implementation will be dispatched 29cb23e90cSJeremy L Thompson // through unless overridden 30cb23e90cSJeremy L Thompson Ceed ceedref; 31adb2481bSnbeams #ifdef HAVE_HIP 32*40461fa4Snbeams CeedInit("/gpu/hip/magma", &ceedref); 33adb2481bSnbeams #else 34*40461fa4Snbeams CeedInit("/gpu/cuda/magma", &ceedref); 35adb2481bSnbeams #endif 36cb23e90cSJeremy L Thompson ierr = CeedSetDelegate(ceed, ceedref); CeedChk(ierr); 37cb23e90cSJeremy L Thompson 38cb23e90cSJeremy L Thompson // Create reference CEED for restriction 39cb23e90cSJeremy L Thompson Ceed restrictionceedref; 40a31f51a5Snbeams #ifdef HAVE_HIP 41a31f51a5Snbeams CeedInit("/gpu/hip/ref", &restrictionceedref); 42a31f51a5Snbeams #else 43461525f5SNatalie Beams CeedInit("/gpu/cuda/ref", &restrictionceedref); 44a31f51a5Snbeams #endif 45cb23e90cSJeremy L Thompson ierr = CeedSetObjectDelegate(ceed, restrictionceedref, "ElemRestriction"); 46cb23e90cSJeremy L Thompson CeedChk(ierr); 47cb23e90cSJeremy L Thompson 48cb23e90cSJeremy L Thompson return 0; 49cb23e90cSJeremy L Thompson } 50cb23e90cSJeremy L Thompson 51cb23e90cSJeremy L Thompson __attribute__((constructor)) 52cb23e90cSJeremy L Thompson static void Register(void) { 53adb2481bSnbeams #ifdef HAVE_HIP 54*40461fa4Snbeams CeedRegister("/gpu/hip/magma/det", CeedInit_Magma_Det, 25); 55adb2481bSnbeams #else 56*40461fa4Snbeams CeedRegister("/gpu/cuda/magma/det", CeedInit_Magma_Det, 25); 57adb2481bSnbeams #endif 58cb23e90cSJeremy L Thompson } 59