1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 #include <ceed.h> 9 #include <ceed/backend.h> 10 #include <stdbool.h> 11 #include <string.h> 12 13 #include "ceed-avx.h" 14 15 //------------------------------------------------------------------------------ 16 // Backend Init 17 //------------------------------------------------------------------------------ 18 static int CeedInit_Avx(const char *resource, Ceed ceed) { 19 CeedCheck(!strcmp(resource, "/cpu/self") || !strcmp(resource, "/cpu/self/avx/serial"), ceed, CEED_ERROR_BACKEND, 20 "AVX backend cannot use resource: %s", resource); 21 CeedCallBackend(CeedSetDeterministic(ceed, true)); 22 23 // Create reference Ceed that implementation will be dispatched through unless overridden 24 Ceed ceed_ref; 25 CeedCallBackend(CeedInit("/cpu/self/opt/serial", &ceed_ref)); 26 CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 27 28 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate", CeedTensorContractCreate_Avx)); 29 30 return CEED_ERROR_SUCCESS; 31 } 32 33 //------------------------------------------------------------------------------ 34 // Backend Register 35 //------------------------------------------------------------------------------ 36 CEED_INTERN int CeedRegister_Avx_Serial(void) { return CeedRegister("/cpu/self/avx/serial", CeedInit_Avx, 35); } 37 38 //------------------------------------------------------------------------------ 39