xref: /honee/include/smartsim.h (revision 8a8cb6e06ce4728cc6d80ca92f8de31da49852e5)
1 // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors.
2 // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause
3 #pragma once
4 
5 #include <c_client.h>
6 #include <petscsys.h>
7 #include <sr_enums.h>
8 
9 #if defined(__clang_analyzer__)
10 void PetscCallSmartRedis(SRError);
11 #else
12 #define PetscCallSmartRedis(...)                                                                                                   \
13   do {                                                                                                                             \
14     SRError   ierr_smartredis_call_q_;                                                                                             \
15     PetscBool disable_calls = PETSC_FALSE;                                                                                         \
16     PetscStackUpdateLine;                                                                                                          \
17     PetscCall(PetscOptionsGetBool(NULL, NULL, "-smartsim_disable_calls", &disable_calls, NULL));                                   \
18     if (disable_calls == PETSC_TRUE) break;                                                                                        \
19     ierr_smartredis_call_q_ = __VA_ARGS__;                                                                                         \
20     if (PetscUnlikely(ierr_smartredis_call_q_ != SRNoError))                                                                       \
21       SETERRQ(PETSC_COMM_SELF, (PetscErrorCode)ierr_smartredis_call_q_, "SmartRedis Error (Code %d): %s", ierr_smartredis_call_q_, \
22               SRGetLastError());                                                                                                   \
23   } while (0)
24 #endif
25 
26 PetscErrorCode SmartRedisVerifyPutTensor(void *c_client, const char *name, const size_t name_length);
27