Skip to content

Commit

Permalink
fluids: Change SmartRedisCall -> PetscSmartRedisCall
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwrigh committed Nov 27, 2023
1 parent 95b1a41 commit 2e3eab9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/fluids/include/smartsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <sr_enums.h>

#if defined(__clang_analyzer__)
void SmartRedisCall(SRError);
void PetscSmartRedisCall(SRError);
#else
#define SmartRedisCall(...) \
#define PetscSmartRedisCall(...) \
do { \
SRError ierr_smartredis_call_q_; \
PetscBool disable_calls = PETSC_FALSE; \
Expand Down
12 changes: 6 additions & 6 deletions examples/fluids/src/smartsim/sgs_dd_training.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ PetscErrorCode SGS_DD_TrainingSetup(Ceed ceed, User user, CeedData ceed_data, Pr
array_info[4] = smartsim->collocated_database_num_ranks;
array_info[5] = rank;

SmartRedisCall(put_tensor(smartsim->client, "sizeInfo", 8, array_info, &array_info_dim, 1, SRTensorTypeInt32, SRMemLayoutContiguous));
PetscSmartRedisCall(put_tensor(smartsim->client, "sizeInfo", 8, array_info, &array_info_dim, 1, SRTensorTypeInt32, SRMemLayoutContiguous));
PetscCall(SmartRedisVerifyPutTensor(smartsim->client, "sizeInfo", 8));

// -- Send array that communicates if tensors are overwritten in database
PetscInt tensor_overwrite[2] = {sgs_dd_train->overwrite_training_data};
size_t dim_2[1] = {2};
SmartRedisCall(put_tensor(smartsim->client, "tensor-ow", 9, tensor_overwrite, dim_2, 1, SRTensorTypeInt32, SRMemLayoutContiguous));
PetscSmartRedisCall(put_tensor(smartsim->client, "tensor-ow", 9, tensor_overwrite, dim_2, 1, SRTensorTypeInt32, SRMemLayoutContiguous));
PetscCall(SmartRedisVerifyPutTensor(smartsim->client, "tensor-ow", 9));
}
}
Expand Down Expand Up @@ -313,16 +313,16 @@ PetscErrorCode TSMonitor_SGS_DD_Training(TS ts, PetscInt step_num, PetscReal sol
{
const PetscScalar *training_data;
PetscCall(VecGetArrayRead(TrainingData, &training_data));
SmartRedisCall(put_tensor(smartsim->client, array_key, array_key_len, (void *)training_data, sgs_dd_train->training_data_array_dims, 2,
SRTensorTypeDouble, SRMemLayoutContiguous));
PetscSmartRedisCall(put_tensor(smartsim->client, array_key, array_key_len, (void *)training_data, sgs_dd_train->training_data_array_dims, 2,
SRTensorTypeDouble, SRMemLayoutContiguous));
PetscCall(VecRestoreArrayRead(TrainingData, &training_data));
}
PetscCall(SmartRedisVerifyPutTensor(smartsim->client, array_key, array_key_len));

if (rank % smartsim->collocated_database_num_ranks == 0) {
size_t dim_2[1] = {2};
PetscInt step_array[2] = {step_num, step_num};
SmartRedisCall(put_tensor(smartsim->client, "step", 4, step_array, dim_2, 1, SRTensorTypeInt32, SRMemLayoutContiguous));
PetscSmartRedisCall(put_tensor(smartsim->client, "step", 4, step_array, dim_2, 1, SRTensorTypeInt32, SRMemLayoutContiguous));
}
}

Expand All @@ -342,7 +342,7 @@ PetscErrorCode TSPostStep_SGS_DD_Training(TS ts) {
PetscCall(TSGetApplicationContext(ts, &user));
SmartSimData smartsim = user->smartsim;

SmartRedisCall(
PetscSmartRedisCall(
unpack_tensor(smartsim->client, check_run_key, check_run_key_size, check_run, check_run_dims, 1, SRTensorTypeDouble, SRMemLayoutContiguous));
if (check_run[0] == 0) {
PetscCall(PetscPrintf(user->comm, "-- Simulation stopped by 'check-run' tensor in Redis database\n"));
Expand Down
8 changes: 4 additions & 4 deletions examples/fluids/src/smartsim/smartsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PetscErrorCode SmartRedisVerifyPutTensor(void *c_client, const char *name, const
bool does_exist = true;

PetscFunctionBeginUser;
SmartRedisCall(tensor_exists(c_client, name, name_length, &does_exist));
PetscSmartRedisCall(tensor_exists(c_client, name, name_length, &does_exist));
PetscCheck(does_exist, PETSC_COMM_SELF, -1, "Tensor of name '%s' was not written to the database successfully", name);
PetscFunctionReturn(PETSC_SUCCESS);
}
Expand All @@ -32,7 +32,7 @@ PetscErrorCode SmartSimTrainingSetup(User user) {

if (rank % smartsim->collocated_database_num_ranks == 0) {
// -- Send array that communicates when ML is done training
SmartRedisCall(put_tensor(smartsim->client, "check-run", 9, checkrun, dim_2, 1, SRTensorTypeDouble, SRMemLayoutContiguous));
PetscSmartRedisCall(put_tensor(smartsim->client, "check-run", 9, checkrun, dim_2, 1, SRTensorTypeDouble, SRMemLayoutContiguous));
PetscCall(SmartRedisVerifyPutTensor(smartsim->client, "check-run", 9));
}
PetscFunctionReturn(PETSC_SUCCESS);
Expand All @@ -58,7 +58,7 @@ PetscErrorCode SmartSimSetup(User user) {
PetscCallMPI(MPI_Comm_rank(user->comm, &rank));
PetscCall(PetscSNPrintf(smartsim->rank_id_name, sizeof smartsim->rank_id_name, "y.%d", rank));

SmartRedisCall(SmartRedisCClient(num_orchestrator_nodes != 1, smartsim->rank_id_name, rank_id_name_len, &smartsim->client));
PetscSmartRedisCall(SmartRedisCClient(num_orchestrator_nodes != 1, smartsim->rank_id_name, rank_id_name_len, &smartsim->client));

PetscCall(SmartSimTrainingSetup(user));
PetscFunctionReturn(PETSC_SUCCESS);
Expand All @@ -68,7 +68,7 @@ PetscErrorCode SmartSimDataDestroy(SmartSimData smartsim) {
PetscFunctionBeginUser;
if (!smartsim) PetscFunctionReturn(PETSC_SUCCESS);

SmartRedisCall(DeleteCClient(&smartsim->client));
PetscSmartRedisCall(DeleteCClient(&smartsim->client));
PetscCall(PetscFree(smartsim));
PetscFunctionReturn(PETSC_SUCCESS);
}

0 comments on commit 2e3eab9

Please sign in to comment.