xref: /honee/include/smartsim.h (revision 20bd4f36636b78bf8d16c55c905ef3a1f3f71a6d)
1 // Copyright (c) 2017-2024, 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 #pragma once
8 
9 #include <c_client.h>
10 #include <petscsys.h>
11 #include <sr_enums.h>
12 
13 #if defined(__clang_analyzer__)
14 void PetscSmartRedisCall(SRError);
15 #else
16 #define PetscSmartRedisCall(...)                                                                                                      \
17   do {                                                                                                                                \
18     SRError   ierr_smartredis_call_q_;                                                                                                \
19     PetscBool disable_calls = PETSC_FALSE;                                                                                            \
20     PetscStackUpdateLine;                                                                                                             \
21     PetscCall(PetscOptionsGetBool(NULL, NULL, "-smartsim_disable_calls", &disable_calls, NULL));                                      \
22     if (disable_calls == PETSC_TRUE) break;                                                                                           \
23     ierr_smartredis_call_q_ = __VA_ARGS__;                                                                                            \
24     if (PetscUnlikely(ierr_smartredis_call_q_ != SRNoError))                                                                          \
25       SETERRQ(PETSC_COMM_SELF, ierr_smartredis_call_q_, "SmartRedis Error (Code %d): %s", ierr_smartredis_call_q_, SRGetLastError()); \
26   } while (0)
27 #endif
28 
29 PetscErrorCode SmartRedisVerifyPutTensor(void *c_client, const char *name, const size_t name_length);
30