xref: /libCEED/rust/libceed-sys/c-src/backends/magma/ceed-magma-det.c (revision a31f51a5b0a1ce23c6fb26346c8db9a8c93d16d5)
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;
21cb23e90cSJeremy L Thompson   if (strcmp(resource, "/gpu/magma/det"))
22cb23e90cSJeremy L Thompson     // LCOV_EXCL_START
23cb23e90cSJeremy L Thompson     return CeedError(ceed, 1, "Magma backend cannot use resource: %s", resource);
24cb23e90cSJeremy L Thompson   // LCOV_EXCL_STOP
25cb23e90cSJeremy L Thompson   ierr = CeedSetDeterministic(ceed, true); CeedChk(ierr);
26cb23e90cSJeremy L Thompson 
27cb23e90cSJeremy L Thompson   // Create reference CEED that implementation will be dispatched
28cb23e90cSJeremy L Thompson   //   through unless overridden
29cb23e90cSJeremy L Thompson   Ceed ceedref;
30cb23e90cSJeremy L Thompson   CeedInit("/gpu/magma", &ceedref);
31cb23e90cSJeremy L Thompson   ierr = CeedSetDelegate(ceed, ceedref); CeedChk(ierr);
32cb23e90cSJeremy L Thompson 
33cb23e90cSJeremy L Thompson   // Create reference CEED for restriction
34cb23e90cSJeremy L Thompson   Ceed restrictionceedref;
35*a31f51a5Snbeams   #ifdef HAVE_HIP
36*a31f51a5Snbeams   CeedInit("/gpu/hip/ref", &restrictionceedref);
37*a31f51a5Snbeams   #else
38461525f5SNatalie Beams   CeedInit("/gpu/cuda/ref", &restrictionceedref);
39*a31f51a5Snbeams   #endif
40cb23e90cSJeremy L Thompson   ierr = CeedSetObjectDelegate(ceed, restrictionceedref, "ElemRestriction");
41cb23e90cSJeremy L Thompson   CeedChk(ierr);
42cb23e90cSJeremy L Thompson 
43cb23e90cSJeremy L Thompson   return 0;
44cb23e90cSJeremy L Thompson }
45cb23e90cSJeremy L Thompson 
46cb23e90cSJeremy L Thompson __attribute__((constructor))
47cb23e90cSJeremy L Thompson static void Register(void) {
48cb23e90cSJeremy L Thompson   CeedRegister("/gpu/magma/det", CeedInit_Magma_Det, 25);
49cb23e90cSJeremy L Thompson }
50