xref: /libCEED/rust/libceed-sys/c-src/backends/avx/ceed-avx-serial.c (revision 80a9ef0545a39c00cdcaab1ca26f8053604f3120)
184a01de5SJeremy L Thompson // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
284a01de5SJeremy L Thompson // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
384a01de5SJeremy L Thompson // All Rights reserved. See files LICENSE and NOTICE for details.
484a01de5SJeremy L Thompson //
584a01de5SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software
684a01de5SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral
784a01de5SJeremy L Thompson // element discretizations for exascale applications. For more information and
884a01de5SJeremy L Thompson // source code availability see http://github.com/ceed.
984a01de5SJeremy L Thompson //
1084a01de5SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
1184a01de5SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office
1284a01de5SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for
1384a01de5SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including
1484a01de5SJeremy L Thompson // software, applications, hardware, advanced system engineering and early
1584a01de5SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative.
1684a01de5SJeremy L Thompson 
17ec3da8bcSJed Brown #include <ceed/ceed.h>
18ec3da8bcSJed Brown #include <ceed/backend.h>
193d576824SJeremy L Thompson #include <stdbool.h>
203d576824SJeremy L Thompson #include <string.h>
2184a01de5SJeremy L Thompson #include "ceed-avx.h"
2284a01de5SJeremy L Thompson 
23f10650afSjeremylt //------------------------------------------------------------------------------
24f10650afSjeremylt // Backend Init
25f10650afSjeremylt //------------------------------------------------------------------------------
2684a01de5SJeremy L Thompson static int CeedInit_Avx(const char *resource, Ceed ceed) {
2784a01de5SJeremy L Thompson   int ierr;
2884a01de5SJeremy L Thompson   if (strcmp(resource, "/cpu/self")
2984a01de5SJeremy L Thompson       && strcmp(resource, "/cpu/self/avx/serial"))
30c042f62fSJeremy L Thompson     // LCOV_EXCL_START
31e15f9bd0SJeremy L Thompson     return CeedError(ceed, CEED_ERROR_BACKEND,
32e15f9bd0SJeremy L Thompson                      "AVX backend cannot use resource: %s", resource);
33c042f62fSJeremy L Thompson   // LCOV_EXCL_STOP
34e15f9bd0SJeremy L Thompson   ierr = CeedSetDeterministic(ceed, true); CeedChkBackend(ierr);
3584a01de5SJeremy L Thompson 
365f67fadeSJeremy L Thompson   // Create reference CEED that implementation will be dispatched
3784a01de5SJeremy L Thompson   //   through unless overridden
38d1d35e2fSjeremylt   Ceed ceed_ref;
39d1d35e2fSjeremylt   CeedInit("/cpu/self/opt/serial", &ceed_ref);
40d1d35e2fSjeremylt   ierr = CeedSetDelegate(ceed, ceed_ref); CeedChkBackend(ierr);
4184a01de5SJeremy L Thompson 
42*80a9ef05SNatalie Beams   if (CEED_SCALAR_TYPE == CEED_SCALAR_FP64) {
432f86a920SJeremy L Thompson     ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate",
44*80a9ef05SNatalie Beams                                   CeedTensorContractCreate_f64_Avx);
45*80a9ef05SNatalie Beams     CeedChkBackend(ierr);
46*80a9ef05SNatalie Beams   } else {
47*80a9ef05SNatalie Beams     ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate",
48*80a9ef05SNatalie Beams                                   CeedTensorContractCreate_f32_Avx);
49*80a9ef05SNatalie Beams     CeedChkBackend(ierr);
50*80a9ef05SNatalie Beams   }
51*80a9ef05SNatalie Beams 
52e15f9bd0SJeremy L Thompson   return CEED_ERROR_SUCCESS;
5384a01de5SJeremy L Thompson }
5484a01de5SJeremy L Thompson 
55f10650afSjeremylt //------------------------------------------------------------------------------
56f10650afSjeremylt // Backend Register
57f10650afSjeremylt //------------------------------------------------------------------------------
581d013790SJed Brown CEED_INTERN int CeedRegister_Avx_Serial(void) {
591d013790SJed Brown   return CeedRegister("/cpu/self/avx/serial", CeedInit_Avx, 35);
6084a01de5SJeremy L Thompson }
61f10650afSjeremylt //------------------------------------------------------------------------------
62