xref: /honee/include/smartsim.h (revision 7ebeccb998f2e038b4992256a1377876ce929ed3)
1ae2b091fSJames Wright // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors.
2ae2b091fSJames Wright // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause
318fb7758SJeremy L Thompson #pragma once
47cd70835SJames Wright 
57cd70835SJames Wright #include <c_client.h>
6*7ebeccb9SJames Wright #include <honee.h>
77cd70835SJames Wright #include <petscsys.h>
87cd70835SJames Wright #include <sr_enums.h>
97cd70835SJames Wright 
107cd70835SJames Wright #if defined(__clang_analyzer__)
1143e9749fSJames Wright void PetscCallSmartRedis(SRError);
127cd70835SJames Wright #else
1343e9749fSJames Wright #define PetscCallSmartRedis(...)                                                                                                   \
147cd70835SJames Wright   do {                                                                                                                             \
157cd70835SJames Wright     SRError   ierr_smartredis_call_q_;                                                                                             \
167cd70835SJames Wright     PetscBool disable_calls = PETSC_FALSE;                                                                                         \
177cd70835SJames Wright     PetscStackUpdateLine;                                                                                                          \
187cd70835SJames Wright     PetscCall(PetscOptionsGetBool(NULL, NULL, "-smartsim_disable_calls", &disable_calls, NULL));                                   \
197cd70835SJames Wright     if (disable_calls == PETSC_TRUE) break;                                                                                        \
207cd70835SJames Wright     ierr_smartredis_call_q_ = __VA_ARGS__;                                                                                         \
217cd70835SJames Wright     if (PetscUnlikely(ierr_smartredis_call_q_ != SRNoError))                                                                       \
224fa1625aSJames Wright       SETERRQ(PETSC_COMM_SELF, (PetscErrorCode)ierr_smartredis_call_q_, "SmartRedis Error (Code %d): %s", ierr_smartredis_call_q_, \
234fa1625aSJames Wright               SRGetLastError());                                                                                                   \
247cd70835SJames Wright   } while (0)
257cd70835SJames Wright #endif
267cd70835SJames Wright 
27*7ebeccb9SJames Wright typedef struct {
28*7ebeccb9SJames Wright   void    *client;
29*7ebeccb9SJames Wright   char     rank_id_name[16];
30*7ebeccb9SJames Wright   PetscInt collocated_database_num_ranks;
31*7ebeccb9SJames Wright } *SmartSimData;
32*7ebeccb9SJames Wright 
33*7ebeccb9SJames Wright PetscErrorCode HoneeGetSmartSimData(Honee honee, SmartSimData *smartsim);
34*7ebeccb9SJames Wright 
357cd70835SJames Wright PetscErrorCode SmartRedisVerifyPutTensor(void *c_client, const char *name, const size_t name_length);
36