xref: /honee/include/smartsim.h (revision 4fa1625a4f8384d952910d1287237123ea0ab4e4)
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, (PetscErrorCode)ierr_smartredis_call_q_, "SmartRedis Error (Code %d): %s", ierr_smartredis_call_q_, \
26               SRGetLastError());                                                                                                   \
27   } while (0)
28 #endif
29 
30 PetscErrorCode SmartRedisVerifyPutTensor(void *c_client, const char *name, const size_t name_length);
31