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 if (strcmp(resource, "/cpu/self") && strcmp(resource, "/cpu/self/avx") && strcmp(resource, "/cpu/self/avx/blocked")) { 20 // LCOV_EXCL_START 21 return CeedError(ceed, CEED_ERROR_BACKEND, "AVX backend cannot use resource: %s", resource); 22 // LCOV_EXCL_STOP 23 } 24 CeedCallBackend(CeedSetDeterministic(ceed, true)); 25 26 // Create reference Ceed that implementation will be dispatched through unless overridden 27 Ceed ceed_ref; 28 CeedCallBackend(CeedInit("/cpu/self/opt/blocked", &ceed_ref)); 29 CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 30 31 if (CEED_SCALAR_TYPE == CEED_SCALAR_FP64) { 32 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate", CeedTensorContractCreate_f64_Avx)); 33 } else { 34 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate", CeedTensorContractCreate_f32_Avx)); 35 } 36 37 return CEED_ERROR_SUCCESS; 38 } 39 40 //------------------------------------------------------------------------------ 41 // Backend Register 42 //------------------------------------------------------------------------------ 43 CEED_INTERN int CeedRegister_Avx_Blocked(void) { return CeedRegister("/cpu/self/avx/blocked", CeedInit_Avx, 30); } 44 45 //------------------------------------------------------------------------------ 46