Skip to content

Commit e3a464e

Browse files
committed
Add a patch to ROMIO to print the number of calls to memcpy()
This is to show the excessive number of calls to memcpy() in macro ADIOI_BUF_COPY of subroutine ADIOI_Fill_send_buffer() in file mpich/src/mpi/romio/adio/common/ad_write_coll.c Run pio_noncontig with the following commands and compare. % mpiexec -n 16 pio_noncontig -k 256 -c 32768 -w Number of global variables = 64 Each global variable is of size 256 x 32768 bytes Each local variable is of size 256 x 16 bytes Gap between the first 2 variables is of size 16 bytes Number of subarray types concatenated is 8192 Each process makes a request of amount 33554688 bytes ROMIO hint set: cb_buffer_size = 1048576 ROMIO hint set: cb_nodes = 4 rank 0: ADIOI_GEN_WriteStridedColl number of memcpy called = 2097153 rank 1: ADIOI_GEN_WriteStridedColl number of memcpy called = 2097153 rank 2: ADIOI_GEN_WriteStridedColl number of memcpy called = 2097153 rank 3: ADIOI_GEN_WriteStridedColl number of memcpy called = 2097153 --------------------------------------------------------- Time of collective write = 30.83 sec --------------------------------------------------------- % mpiexec -n 16 pio_noncontig -k 256 -c 32768 -w -g 0 Number of global variables = 64 Each global variable is of size 256 x 32768 bytes Each local variable is of size 256 x 16 bytes Gap between the first 2 variables is of size 0 bytes Number of subarray types concatenated is 8192 Each process makes a request of amount 33554688 bytes ROMIO hint set: cb_buffer_size = 1048576 ROMIO hint set: cb_nodes = 4 rank 0: ADIOI_GEN_WriteStridedColl number of memcpy called = 0 rank 1: ADIOI_GEN_WriteStridedColl number of memcpy called = 0 rank 2: ADIOI_GEN_WriteStridedColl number of memcpy called = 0 rank 3: ADIOI_GEN_WriteStridedColl number of memcpy called = 0 --------------------------------------------------------- Time of collective write = 9.27 sec ---------------------------------------------------------
1 parent 7426408 commit e3a464e

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From 82487c29f5737b8f4c959a8dfc148d52deed0c51 Mon Sep 17 00:00:00 2001
2+
From: wkliao <wkliao@users.noreply.github.com>
3+
Date: Thu, 18 Apr 2024 15:44:46 -0500
4+
Subject: [PATCH] print number of calls to memcpy()
5+
6+
---
7+
src/mpi/romio/adio/common/ad_write_coll.c | 6 ++++++
8+
1 file changed, 6 insertions(+)
9+
10+
diff --git a/src/mpi/romio/adio/common/ad_write_coll.c b/src/mpi/romio/adio/common/ad_write_coll.c
11+
index 2b7ed69f..84c5875d 100644
12+
--- a/src/mpi/romio/adio/common/ad_write_coll.c
13+
+++ b/src/mpi/romio/adio/common/ad_write_coll.c
14+
@@ -10,6 +10,8 @@
15+
#include "mpe.h"
16+
#endif
17+
18+
+static int num_memcpy;
19+
+
20+
/* prototypes of functions used for collective writes only. */
21+
static void ADIOI_Exch_and_write(ADIO_File fd, void *buf, MPI_Datatype
22+
datatype, int nprocs, int myrank,
23+
@@ -78,6 +80,7 @@ void ADIOI_GEN_WriteStridedColl(ADIO_File fd, const void *buf, MPI_Aint count,
24+
ADIO_Offset *len_list = NULL;
25+
int old_error, tmp_error;
26+
27+
+num_memcpy = 0;
28+
if (fd->hints->cb_pfr != ADIOI_HINT_DISABLE) {
29+
/* Cast away const'ness as the below function is used for read
30+
* and write */
31+
@@ -247,6 +250,8 @@ void ADIOI_GEN_WriteStridedColl(ADIO_File fd, const void *buf, MPI_Aint count,
32+
#ifdef AGGREGATION_PROFILE
33+
MPE_Log_event(5013, 0, NULL);
34+
#endif
35+
+
36+
+if (fd->is_agg) printf("rank %d: %s number of memcpy called = %d\n",myrank,__func__,num_memcpy);
37+
}
38+
39+
40+
@@ -791,6 +796,7 @@ static void ADIOI_W_Exchange_data(ADIO_File fd, void *buf, char *write_buf,
41+
ADIOI_Assert(size_in_buf == (size_t)size_in_buf); \
42+
memcpy(&(send_buf[p][send_buf_idx[p]]), \
43+
((char *) buf) + user_buf_idx, size_in_buf); \
44+
+num_memcpy++; \
45+
send_buf_idx[p] += size_in_buf; \
46+
user_buf_idx += size_in_buf; \
47+
flat_buf_sz -= size_in_buf; \
48+
--
49+
2.39.3
50+

0 commit comments

Comments
 (0)