19ae013d6SJames Wright // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors. 29ae013d6SJames Wright // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause 39ae013d6SJames Wright #pragma once 49ae013d6SJames Wright 59ae013d6SJames Wright #include <c_client.h> 6*1fc84d60SJames Wright #include <c_dataset.h> 79ae013d6SJames Wright #include <honee.h> 89ae013d6SJames Wright #include <petscsys.h> 99ae013d6SJames Wright #include <smartsim.h> 109ae013d6SJames Wright #include <sr_enums.h> 119ae013d6SJames Wright 129ae013d6SJames Wright #if defined(__clang_analyzer__) 139ae013d6SJames Wright void PetscCallSmartRedis(SRError); 149ae013d6SJames Wright #else 159ae013d6SJames Wright #define PetscCallSmartRedis(...) \ 169ae013d6SJames Wright do { \ 179ae013d6SJames Wright SRError ierr_smartredis_call_q_; \ 189ae013d6SJames Wright PetscBool disable_calls = PETSC_FALSE; \ 199ae013d6SJames Wright PetscStackUpdateLine; \ 209ae013d6SJames Wright PetscCall(PetscOptionsGetBool(NULL, NULL, "-smartsim_disable_calls", &disable_calls, NULL)); \ 219ae013d6SJames Wright if (disable_calls == PETSC_TRUE) break; \ 229ae013d6SJames Wright ierr_smartredis_call_q_ = __VA_ARGS__; \ 239ae013d6SJames Wright if (PetscUnlikely(ierr_smartredis_call_q_ != SRNoError)) \ 249ae013d6SJames Wright SETERRQ(PETSC_COMM_SELF, (PetscErrorCode)ierr_smartredis_call_q_, "SmartRedis Error (Code %d): %s", ierr_smartredis_call_q_, \ 259ae013d6SJames Wright SRGetLastError()); \ 269ae013d6SJames Wright } while (0) 279ae013d6SJames Wright #endif 289ae013d6SJames Wright 299ae013d6SJames Wright typedef struct { 309ae013d6SJames Wright void *client; 319ae013d6SJames Wright char rank_id_name[16]; 329ae013d6SJames Wright PetscInt collocated_database_num_ranks; 339ae013d6SJames Wright } *SmartSimData; 349ae013d6SJames Wright 359ae013d6SJames Wright PetscErrorCode HoneeGetSmartSimData(Honee honee, SmartSimData *smartsim); 369ae013d6SJames Wright 379ae013d6SJames Wright PetscErrorCode SmartRedisVerifyPutTensor(void *c_client, const char *name, const size_t name_length); 38*1fc84d60SJames Wright 39*1fc84d60SJames Wright #if defined(PETSC_USE_64BIT_INDICES) 40*1fc84d60SJames Wright #define SRMetadataTypePetscInt SRMetadataTypeInt64 41*1fc84d60SJames Wright #else 42*1fc84d60SJames Wright #define SRMetadataTypePetscInt SRMetadataTypeInt32 43*1fc84d60SJames Wright #endif 44