xref: /honee/include/smartsim.h (revision 9b05e62e4a81b29e40cfcd7da7a7fab1171c8eb3)
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 <honee.h>
7 #include <petscsys.h>
8 #include <sr_enums.h>
9 
10 #if defined(__clang_analyzer__)
11 void PetscCallSmartRedis(SRError);
12 #else
13 #define PetscCallSmartRedis(...)                                                                                                   \
14   do {                                                                                                                             \
15     SRError   ierr_smartredis_call_q_;                                                                                             \
16     PetscBool disable_calls = PETSC_FALSE;                                                                                         \
17     PetscStackUpdateLine;                                                                                                          \
18     PetscCall(PetscOptionsGetBool(NULL, NULL, "-smartsim_disable_calls", &disable_calls, NULL));                                   \
19     if (disable_calls == PETSC_TRUE) break;                                                                                        \
20     ierr_smartredis_call_q_ = __VA_ARGS__;                                                                                         \
21     if (PetscUnlikely(ierr_smartredis_call_q_ != SRNoError))                                                                       \
22       SETERRQ(PETSC_COMM_SELF, (PetscErrorCode)ierr_smartredis_call_q_, "SmartRedis Error (Code %d): %s", ierr_smartredis_call_q_, \
23               SRGetLastError());                                                                                                   \
24   } while (0)
25 #endif
26 
27 typedef struct {
28   void    *client;
29   char     rank_id_name[16];
30   PetscInt collocated_database_num_ranks;
31 } *SmartSimData;
32 
33 PetscErrorCode HoneeGetSmartSimData(Honee honee, SmartSimData *smartsim);
34 
35 PetscErrorCode SmartRedisVerifyPutTensor(void *c_client, const char *name, const size_t name_length);
36