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 17*3d576824SJeremy L Thompson #include <ceed.h> 18*3d576824SJeremy L Thompson #include <ceed-backend.h> 19cb23e90cSJeremy L Thompson #include "ceed-magma.h" 20cb23e90cSJeremy L Thompson 211d013790SJed Brown CEED_INTERN int CeedInit_Magma_Det(const char *resource, Ceed ceed) { 22cb23e90cSJeremy L Thompson int ierr; 2340461fa4Snbeams if (strcmp(resource, "/gpu/cuda/magma/det") 2440461fa4Snbeams && strcmp(resource, "/gpu/hip/magma/det")) 25cb23e90cSJeremy L Thompson // LCOV_EXCL_START 26cb23e90cSJeremy L Thompson return CeedError(ceed, 1, "Magma backend cannot use resource: %s", resource); 27cb23e90cSJeremy L Thompson // LCOV_EXCL_STOP 28cb23e90cSJeremy L Thompson ierr = CeedSetDeterministic(ceed, true); CeedChk(ierr); 29cb23e90cSJeremy L Thompson 30cb23e90cSJeremy L Thompson // Create reference CEED that implementation will be dispatched 31cb23e90cSJeremy L Thompson // through unless overridden 32cb23e90cSJeremy L Thompson Ceed ceedref; 33adb2481bSnbeams #ifdef HAVE_HIP 3440461fa4Snbeams CeedInit("/gpu/hip/magma", &ceedref); 35adb2481bSnbeams #else 3640461fa4Snbeams CeedInit("/gpu/cuda/magma", &ceedref); 37adb2481bSnbeams #endif 38cb23e90cSJeremy L Thompson ierr = CeedSetDelegate(ceed, ceedref); CeedChk(ierr); 39cb23e90cSJeremy L Thompson 40cb23e90cSJeremy L Thompson // Create reference CEED for restriction 41cb23e90cSJeremy L Thompson Ceed restrictionceedref; 42a31f51a5Snbeams #ifdef HAVE_HIP 43a31f51a5Snbeams CeedInit("/gpu/hip/ref", &restrictionceedref); 44a31f51a5Snbeams #else 45461525f5SNatalie Beams CeedInit("/gpu/cuda/ref", &restrictionceedref); 46a31f51a5Snbeams #endif 47cb23e90cSJeremy L Thompson ierr = CeedSetObjectDelegate(ceed, restrictionceedref, "ElemRestriction"); 48cb23e90cSJeremy L Thompson CeedChk(ierr); 49cb23e90cSJeremy L Thompson 50cb23e90cSJeremy L Thompson return 0; 51cb23e90cSJeremy L Thompson } 52cb23e90cSJeremy L Thompson 531d013790SJed Brown CEED_INTERN int CeedRegister_Magma_Det(void) { 54adb2481bSnbeams #ifdef HAVE_HIP 551d013790SJed Brown return CeedRegister("/gpu/hip/magma/det", CeedInit_Magma_Det, 125); 56adb2481bSnbeams #else 571d013790SJed Brown return CeedRegister("/gpu/cuda/magma/det", CeedInit_Magma_Det, 125); 58adb2481bSnbeams #endif 59cb23e90cSJeremy L Thompson } 60