Skip to content

Commit bbd7c85

Browse files
committed
TOOLS/PERF: Reject extra positional arguments and improve log
1 parent c4fb300 commit bbd7c85

6 files changed

Lines changed: 49 additions & 38 deletions

File tree

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#
22
# UCP basic device cuda tests
33
#
4-
ucp_device_cuda_lat_8b_1thread -t ucp_put_lat -m cuda -s 8 -n 10000
5-
ucp_device_cuda_bw_1k_1thread -t ucp_put_bw -m cuda -s 1024 -n 10000
6-
ucp_device_cuda_lat_1k_1thread -t ucp_put_lat -m cuda -s 1024 -n 10000
4+
ucp_device_cuda_lat_8b_1thread -t ucp_put_lat -m cuda:0 -s 8 -n 10000
5+
ucp_device_cuda_bw_1k_1thread -t ucp_put_bw -m cuda:0 -s 1024 -n 10000
6+
ucp_device_cuda_lat_1k_1thread -t ucp_put_lat -m cuda:0 -s 1024 -n 10000
77

88
# Increase number of threads after following fixes:
99
# - Use thread-local memory instead of shared for requests (limit 48K)
1010
# - Fix WQE size limit of 1024
11-
ucp_device_cuda_bw_1k_32threads -t ucp_put_bw -m cuda -s 1024 -n 10000 -T 32
12-
ucp_device_cuda_lat_1k_32threads -t ucp_put_lat -m cuda -s 1024 -n 10000 -T 32
11+
ucp_device_cuda_bw_1k_32threads -t ucp_put_bw -m cuda:0 -s 1024 -n 10000 -T 32
12+
ucp_device_cuda_lat_1k_32threads -t ucp_put_lat -m cuda:0 -s 1024 -n 10000 -T 32
1313

14-
ucp_device_cuda_bw_1k_1warp -t ucp_put_bw -m cuda -s 1024 -n 10000 -T 32 -L warp
15-
ucp_device_cuda_lat_1k_1warp -t ucp_put_lat -m cuda -s 1024 -n 10000 -T 32 -L warp
14+
ucp_device_cuda_bw_1k_1warp -t ucp_put_bw -m cuda:0 -s 1024 -n 10000 -T 32 -L warp
15+
ucp_device_cuda_lat_1k_1warp -t ucp_put_lat -m cuda:0 -s 1024 -n 10000 -T 32 -L warp

‎src/tools/perf/cuda/cuda_alloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static ucs_status_t ucx_perf_cuda_init(ucx_perf_context_t *perf)
2929

3030
CUDA_CALL_RET(UCS_ERR_NO_DEVICE, cudaGetDeviceCount, &num_gpus);
3131
status = ucx_perf_get_device_index(perf, group_index, num_gpus,
32-
&gpu_index);
32+
"cuda", &gpu_index);
3333
if (status != UCS_OK) {
3434
return status;
3535
}

‎src/tools/perf/lib/libperf_int.h‎

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -227,34 +227,6 @@ struct ucx_perf_context {
227227
};
228228
};
229229

230-
static inline ucs_status_t
231-
ucx_perf_get_device_index(const ucx_perf_context_t *perf,
232-
unsigned group_index, unsigned device_count,
233-
unsigned *device_index_p)
234-
{
235-
int device_id = (group_index == 0) ? perf->params.recv_device_id :
236-
perf->params.send_device_id;
237-
238-
if (device_count == 0) {
239-
ucs_error("no accelerator devices available");
240-
return UCS_ERR_NO_DEVICE;
241-
}
242-
243-
if (device_id == UCX_PERF_MEM_DEV_DEFAULT) {
244-
*device_index_p = group_index % device_count;
245-
return UCS_OK;
246-
}
247-
248-
if ((device_id < 0) || ((unsigned)device_id >= device_count)) {
249-
ucs_error("device index %d is invalid for %u available devices",
250-
device_id, device_count);
251-
return UCS_ERR_NO_DEVICE;
252-
}
253-
254-
*device_index_p = device_id;
255-
return UCS_OK;
256-
}
257-
258230
struct ucx_perf_thread_context {
259231
pthread_t pt;
260232
int tid;
@@ -365,6 +337,37 @@ ucx_perf_mem_alloc_name(const ucx_perf_params_t *params, int is_send)
365337
return ucs_memory_type_names[mem_type];
366338
}
367339

340+
static inline ucs_status_t
341+
ucx_perf_get_device_index(const ucx_perf_context_t *perf,
342+
unsigned group_index, unsigned device_count,
343+
const char *device_type,
344+
unsigned *device_index_p)
345+
{
346+
int device_id;
347+
348+
device_id = (group_index == 0) ? perf->params.recv_device_id :
349+
perf->params.send_device_id;
350+
351+
if (device_count == 0) {
352+
ucs_error("no %s devices available", device_type);
353+
return UCS_ERR_NO_DEVICE;
354+
}
355+
356+
if (device_id == UCX_PERF_MEM_DEV_DEFAULT) {
357+
*device_index_p = group_index % device_count;
358+
return UCS_OK;
359+
}
360+
361+
if ((device_id < 0) || ((unsigned)device_id >= device_count)) {
362+
ucs_error("%s device index %d is invalid for %u available devices",
363+
device_type, device_id, device_count);
364+
return UCS_ERR_NO_DEVICE;
365+
}
366+
367+
*device_index_p = device_id;
368+
return UCS_OK;
369+
}
370+
368371
static UCS_F_ALWAYS_INLINE int ucx_perf_context_done(ucx_perf_context_t *perf)
369372
{
370373
return ucs_unlikely((perf->current.iters >= perf->max_iter) ||

‎src/tools/perf/perftest_params.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,13 @@ ucs_status_t parse_opts(struct perftest_context *ctx, int mpi_initialized,
10331033
goto err;
10341034
}
10351035

1036+
if ((argc - optind) > 1) {
1037+
ucs_error("expected at most one server address argument, got %d",
1038+
argc - optind);
1039+
status = UCS_ERR_INVALID_PARAM;
1040+
goto err;
1041+
}
1042+
10361043
if (optind < argc) {
10371044
ctx->server_addr = argv[optind];
10381045

‎src/tools/perf/rocm/rocm_alloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static ucs_status_t ucx_perf_rocm_init(ucx_perf_context_t *perf)
3131
}
3232

3333
status = ucx_perf_get_device_index(perf, group_index, num_gpus,
34-
&gpu_index);
34+
"rocm", &gpu_index);
3535
if (status != UCS_OK) {
3636
return status;
3737
}

‎src/tools/perf/ze/ze_alloc.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ static ucs_status_t ucx_perf_ze_init(ucx_perf_context_t *perf)
118118
}
119119

120120
group_index = rte_call(perf, group_index);
121-
status = ucx_perf_get_device_index(perf, group_index, gpu_count, &i);
121+
status = ucx_perf_get_device_index(perf, group_index, gpu_count, "ze",
122+
&i);
122123
if (status != UCS_OK) {
123124
return status;
124125
}

0 commit comments

Comments
 (0)