Skip to content

Commit e23dcca

Browse files
committed
Add missing free calls to osc/ucx
Signed-off-by: Joseph Schuchart <schuchart@hlrs.de>
1 parent ede3c08 commit e23dcca

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

ompi/mca/osc/ucx/osc_ucx_active_target.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,16 @@ int ompi_osc_ucx_start(struct ompi_group_t *group, int assert, struct ompi_win_t
110110

111111
ret = ompi_comm_group(module->comm, &win_group);
112112
if (ret != OMPI_SUCCESS) {
113+
free(ranks_in_grp);
114+
free(ranks_in_win_grp);
113115
return OMPI_ERROR;
114116
}
115117

116118
ret = ompi_group_translate_ranks(module->start_group, size, ranks_in_grp,
117119
win_group, ranks_in_win_grp);
118120
if (ret != OMPI_SUCCESS) {
121+
free(ranks_in_grp);
122+
free(ranks_in_win_grp);
119123
return OMPI_ERROR;
120124
}
121125

@@ -215,6 +219,11 @@ int ompi_osc_ucx_post(struct ompi_group_t *group, int assert, struct ompi_win_t
215219
int *ranks_in_grp = NULL, *ranks_in_win_grp = NULL;
216220
int myrank = ompi_comm_rank(module->comm);
217221

222+
ret = ompi_comm_group(module->comm, &win_group);
223+
if (ret != OMPI_SUCCESS) {
224+
return OMPI_ERROR;
225+
}
226+
218227
size = ompi_group_size(module->post_group);
219228
ranks_in_grp = malloc(sizeof(int) * size);
220229
ranks_in_win_grp = malloc(sizeof(int) * ompi_comm_size(module->comm));
@@ -223,15 +232,11 @@ int ompi_osc_ucx_post(struct ompi_group_t *group, int assert, struct ompi_win_t
223232
ranks_in_grp[i] = i;
224233
}
225234

226-
ret = ompi_comm_group(module->comm, &win_group);
227-
if (ret != OMPI_SUCCESS) {
228-
return OMPI_ERROR;
229-
}
230-
231235
ret = ompi_group_translate_ranks(module->post_group, size, ranks_in_grp,
232236
win_group, ranks_in_win_grp);
233237
if (ret != OMPI_SUCCESS) {
234-
return OMPI_ERROR;
238+
ret = OMPI_ERROR;
239+
goto cleanup;
235240
}
236241

237242
for (i = 0; i < size; i++) {
@@ -243,7 +248,8 @@ int ompi_osc_ucx_post(struct ompi_group_t *group, int assert, struct ompi_win_t
243248
1, ranks_in_win_grp[i], &result,
244249
sizeof(result), remote_addr);
245250
if (ret != OMPI_SUCCESS) {
246-
return OMPI_ERROR;
251+
ret = OMPI_ERROR;
252+
goto cleanup;
247253
}
248254

249255
curr_idx = result & (OMPI_OSC_UCX_POST_PEER_MAX - 1);
@@ -256,7 +262,8 @@ int ompi_osc_ucx_post(struct ompi_group_t *group, int assert, struct ompi_win_t
256262
myrank + 1, &result, sizeof(result),
257263
remote_addr);
258264
if (ret != OMPI_SUCCESS) {
259-
return OMPI_ERROR;
265+
ret = OMPI_ERROR;
266+
goto cleanup;
260267
}
261268

262269
if (result == 0)
@@ -277,9 +284,11 @@ int ompi_osc_ucx_post(struct ompi_group_t *group, int assert, struct ompi_win_t
277284
} while (1);
278285
}
279286

287+
cleanup:
280288
free(ranks_in_grp);
281289
free(ranks_in_win_grp);
282290
ompi_group_free(&win_group);
291+
if (OMPI_SUCCESS != ret) return ret;
283292
}
284293

285294
module->epoch_type.exposure = POST_WAIT_EPOCH;

ompi/mca/osc/ucx/osc_ucx_comm.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ static inline int ddt_put_get(ompi_osc_ucx_module_t *module,
133133
ret = create_iov_list(origin_addr, origin_count, origin_dt,
134134
&origin_ucx_iov, &origin_ucx_iov_count);
135135
if (ret != OMPI_SUCCESS) {
136-
return ret;
136+
goto cleanup;
137137
}
138138
}
139139

140140
if (!is_target_contig) {
141141
ret = create_iov_list(NULL, target_count, target_dt,
142142
&target_ucx_iov, &target_ucx_iov_count);
143143
if (ret != OMPI_SUCCESS) {
144-
return ret;
144+
goto cleanup;
145145
}
146146
}
147147

@@ -161,7 +161,8 @@ static inline int ddt_put_get(ompi_osc_ucx_module_t *module,
161161
remote_addr + (uint64_t)(target_ucx_iov[target_ucx_iov_idx].addr));
162162
if (OPAL_SUCCESS != status) {
163163
OSC_UCX_VERBOSE(1, "opal_common_ucx_mem_putget failed: %d", status);
164-
return OMPI_ERROR;
164+
ret = OMPI_ERROR;
165+
goto cleanup;
165166
}
166167

167168
origin_ucx_iov[origin_ucx_iov_idx].addr = (void *)((intptr_t)origin_ucx_iov[origin_ucx_iov_idx].addr + curr_len);
@@ -195,7 +196,8 @@ static inline int ddt_put_get(ompi_osc_ucx_module_t *module,
195196
remote_addr + target_lb + prev_len);
196197
if (OPAL_SUCCESS != status) {
197198
OSC_UCX_VERBOSE(1, "opal_common_ucx_mem_putget failed: %d", status);
198-
return OMPI_ERROR;
199+
ret = OMPI_ERROR;
200+
goto cleanup;
199201
}
200202

201203
prev_len += origin_ucx_iov[origin_ucx_iov_idx].len;
@@ -217,14 +219,17 @@ static inline int ddt_put_get(ompi_osc_ucx_module_t *module,
217219
remote_addr + (uint64_t)(target_ucx_iov[target_ucx_iov_idx].addr));
218220
if (OPAL_SUCCESS != status) {
219221
OSC_UCX_VERBOSE(1, "opal_common_ucx_mem_putget failed: %d", status);
220-
return OMPI_ERROR;
222+
ret = OMPI_ERROR;
223+
goto cleanup;
221224
}
222225

223226
prev_len += target_ucx_iov[target_ucx_iov_idx].len;
224227
target_ucx_iov_idx++;
225228
}
226229
}
227230

231+
cleanup:
232+
228233
if (origin_ucx_iov != NULL) {
229234
free(origin_ucx_iov);
230235
}
@@ -291,12 +296,14 @@ static inline int get_dynamic_win_info(uint64_t remote_addr, ompi_osc_ucx_module
291296
len, remote_state_addr);
292297
if (OPAL_SUCCESS != ret) {
293298
OSC_UCX_VERBOSE(1, "opal_common_ucx_mem_putget failed: %d", ret);
294-
return OMPI_ERROR;
299+
ret = OMPI_ERROR;
300+
goto cleanup;
295301
}
296302

297303
ret = opal_common_ucx_wpmem_flush(module->state_mem, OPAL_COMMON_UCX_SCOPE_EP, target);
298-
if (ret != OMPI_SUCCESS) {
299-
return ret;
304+
if (ret != OPAL_SUCCESS) {
305+
ret = OMPI_ERROR;
306+
goto cleanup;
300307
}
301308

302309
memcpy(&win_count, temp_buf, sizeof(uint64_t));
@@ -318,6 +325,7 @@ static inline int get_dynamic_win_info(uint64_t remote_addr, ompi_osc_ucx_module
318325
temp_dynamic_wins[contain].mem_addr, OMPI_OSC_UCX_MEM_ADDR_MAX_LEN);
319326
module->local_dynamic_win_info[contain].mem->mem_displs[target] = target * OMPI_OSC_UCX_MEM_ADDR_MAX_LEN;
320327

328+
cleanup:
321329
free(temp_buf);
322330

323331
return ret;
@@ -486,11 +494,13 @@ int ompi_osc_ucx_accumulate(const void *origin_addr, int origin_count,
486494
ret = ompi_osc_ucx_get(temp_addr, (int)temp_count, temp_dt,
487495
target, target_disp, target_count, target_dt, win);
488496
if (ret != OMPI_SUCCESS) {
497+
free(temp_addr);
489498
return ret;
490499
}
491500

492501
ret = opal_common_ucx_wpmem_flush(module->mem, OPAL_COMMON_UCX_SCOPE_EP, target);
493502
if (ret != OMPI_SUCCESS) {
503+
free(temp_addr);
494504
return ret;
495505
}
496506

@@ -504,6 +514,7 @@ int ompi_osc_ucx_accumulate(const void *origin_addr, int origin_count,
504514
ret = create_iov_list(origin_addr, origin_count, origin_dt,
505515
&origin_ucx_iov, &origin_ucx_iov_count);
506516
if (ret != OMPI_SUCCESS) {
517+
free(temp_addr);
507518
return ret;
508519
}
509520

@@ -541,11 +552,13 @@ int ompi_osc_ucx_accumulate(const void *origin_addr, int origin_count,
541552
ret = ompi_osc_ucx_put(temp_addr, (int)temp_count, temp_dt, target, target_disp,
542553
target_count, target_dt, win);
543554
if (ret != OMPI_SUCCESS) {
555+
free(temp_addr);
544556
return ret;
545557
}
546558

547559
ret = opal_common_ucx_wpmem_flush(module->mem, OPAL_COMMON_UCX_SCOPE_EP, target);
548560
if (ret != OMPI_SUCCESS) {
561+
free(temp_addr);
549562
return ret;
550563
}
551564

0 commit comments

Comments
 (0)