From 2e3eab96817c677e3bece99807f0a3ddbf4d94af Mon Sep 17 00:00:00 2001 From: James Wright Date: Mon, 27 Nov 2023 13:36:04 -0700 Subject: [PATCH] fluids: Change SmartRedisCall -> PetscSmartRedisCall --- examples/fluids/include/smartsim.h | 4 ++-- examples/fluids/src/smartsim/sgs_dd_training.c | 12 ++++++------ examples/fluids/src/smartsim/smartsim.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/fluids/include/smartsim.h b/examples/fluids/include/smartsim.h index e9bc9b9d3a..c8c1c167fe 100644 --- a/examples/fluids/include/smartsim.h +++ b/examples/fluids/include/smartsim.h @@ -10,9 +10,9 @@ #include #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; \ diff --git a/examples/fluids/src/smartsim/sgs_dd_training.c b/examples/fluids/src/smartsim/sgs_dd_training.c index 0f8e79fa7d..352d850bd6 100644 --- a/examples/fluids/src/smartsim/sgs_dd_training.c +++ b/examples/fluids/src/smartsim/sgs_dd_training.c @@ -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)); } } @@ -313,8 +313,8 @@ 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)); @@ -322,7 +322,7 @@ PetscErrorCode TSMonitor_SGS_DD_Training(TS ts, PetscInt step_num, PetscReal sol 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)); } } @@ -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")); diff --git a/examples/fluids/src/smartsim/smartsim.c b/examples/fluids/src/smartsim/smartsim.c index f03d12042e..2f585fd3e6 100644 --- a/examples/fluids/src/smartsim/smartsim.c +++ b/examples/fluids/src/smartsim/smartsim.c @@ -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); } @@ -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); @@ -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); @@ -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); }