xref: /libCEED/rust/libceed-sys/c-src/backends/magma/ceed-magma-det.c (revision ec3da8bcb94d9f0073544b37b5081a06981a86f7)
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*ec3da8bcSJed Brown #include <ceed/ceed.h>
18*ec3da8bcSJed Brown #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
26e15f9bd0SJeremy L Thompson     return CeedError(ceed, CEED_ERROR_BACKEND,
27e15f9bd0SJeremy L Thompson                      "Magma backend cannot use resource: %s", resource);
28cb23e90cSJeremy L Thompson   // LCOV_EXCL_STOP
29e15f9bd0SJeremy L Thompson   ierr = CeedSetDeterministic(ceed, true); CeedChkBackend(ierr);
30cb23e90cSJeremy L Thompson 
31cb23e90cSJeremy L Thompson   // Create reference CEED that implementation will be dispatched
32cb23e90cSJeremy L Thompson   //   through unless overridden
33cb23e90cSJeremy L Thompson   Ceed ceedref;
34adb2481bSnbeams   #ifdef HAVE_HIP
3540461fa4Snbeams   CeedInit("/gpu/hip/magma", &ceedref);
36adb2481bSnbeams   #else
3740461fa4Snbeams   CeedInit("/gpu/cuda/magma", &ceedref);
38adb2481bSnbeams   #endif
39e15f9bd0SJeremy L Thompson   ierr = CeedSetDelegate(ceed, ceedref); CeedChkBackend(ierr);
40cb23e90cSJeremy L Thompson 
41cb23e90cSJeremy L Thompson   // Create reference CEED for restriction
42cb23e90cSJeremy L Thompson   Ceed restrictionceedref;
43a31f51a5Snbeams   #ifdef HAVE_HIP
44a31f51a5Snbeams   CeedInit("/gpu/hip/ref", &restrictionceedref);
45a31f51a5Snbeams   #else
46461525f5SNatalie Beams   CeedInit("/gpu/cuda/ref", &restrictionceedref);
47a31f51a5Snbeams   #endif
48cb23e90cSJeremy L Thompson   ierr = CeedSetObjectDelegate(ceed, restrictionceedref, "ElemRestriction");
49e15f9bd0SJeremy L Thompson   CeedChkBackend(ierr);
50cb23e90cSJeremy L Thompson 
51e15f9bd0SJeremy L Thompson   return CEED_ERROR_SUCCESS;
52cb23e90cSJeremy L Thompson }
53cb23e90cSJeremy L Thompson 
541d013790SJed Brown CEED_INTERN int CeedRegister_Magma_Det(void) {
55adb2481bSnbeams   #ifdef HAVE_HIP
561d013790SJed Brown   return CeedRegister("/gpu/hip/magma/det", CeedInit_Magma_Det, 125);
57adb2481bSnbeams   #else
581d013790SJed Brown   return CeedRegister("/gpu/cuda/magma/det", CeedInit_Magma_Det, 125);
59adb2481bSnbeams   #endif
60cb23e90cSJeremy L Thompson }
61