Skip to content

Commit ee8e53a

Browse files
committed
file: add no-accelerator assertion flag
- add a new flag indicating that the user guarantueed not to use accelerator memory with a particular file. - check that flag in common_ompio_check_gpu_buf() and return immediatly `false` if the flag is set, i.e. bypassing the accelerator check_addr() routine (which is supposed to be the expensive part). Signed-off-by: Edgar Gabriel <Edgar.Gabriel@amd.com>
1 parent 994869e commit ee8e53a

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

ompi/file/file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
1919
* Copyright (c) 2024 Triad National Security, LLC. All rights
2020
* reserved.
21-
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
21+
* Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
2222
* $COPYRIGHT$
2323
*
2424
* Additional copyrights may follow
@@ -126,7 +126,9 @@ int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,
126126
}
127127
ompi_info_memkind_assert_type type;
128128
ompi_info_memkind_copy_or_set (&comm->instance->super, &file->super, info, &type);
129-
129+
if (OMPI_INFO_MEMKIND_ASSERT_NO_ACCEL == type) {
130+
file->f_flags |= OMPI_FILE_ASSERT_NO_ACCEL_BUF;
131+
}
130132
file->f_amode = amode;
131133
file->f_filename = strdup(filename);
132134
if (NULL == file->f_filename) {

ompi/file/file.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
/*
4040
* Flags
4141
*/
42-
#define OMPI_FILE_ISCLOSED 0x00000001
43-
#define OMPI_FILE_HIDDEN 0x00000002
44-
42+
#define OMPI_FILE_ISCLOSED 0x00000001
43+
#define OMPI_FILE_HIDDEN 0x00000002
44+
#define OMPI_FILE_ASSERT_NO_ACCEL_BUF 0x00000004
4545
BEGIN_C_DECLS
4646

4747
/**

ompi/mca/common/ompio/common_ompio_buffer.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
1313
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
14+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
1415
* $COPYRIGHT$
1516
*
1617
* Additional copyrights may follow
@@ -47,7 +48,11 @@ void mca_common_ompio_check_gpu_buf ( ompio_file_t *fh, const void *buf, int *is
4748

4849
*is_gpu=0;
4950
*is_managed=0;
50-
51+
52+
if (fh->f_fh->f_flags & OMPI_FILE_ASSERT_NO_ACCEL_BUF) {
53+
return;
54+
}
55+
5156
if (0 < opal_accelerator.check_addr(buf, &dev_id, &flags)) {
5257
*is_gpu = 1;
5358
if (flags & MCA_ACCELERATOR_FLAGS_UNIFIED_MEMORY) {
@@ -62,16 +67,14 @@ static void* mca_common_ompio_buffer_alloc_seg ( void*ctx, size_t *size )
6267
{
6368
char *buf=NULL;
6469
size_t realsize, numpages;
65-
uint64_t flags = 0;
66-
int dev_id;
6770

6871
numpages = (*size + mca_common_ompio_pagesize -1 )/mca_common_ompio_pagesize;
6972
realsize = numpages * mca_common_ompio_pagesize;
7073

71-
buf = malloc ( realsize);
74+
buf = malloc (realsize);
7275

73-
if (NULL != buf && 0 == opal_accelerator.check_addr(buf, &dev_id, &flags)) {
74-
opal_accelerator.host_register(dev_id, (void *)buf, realsize);
76+
if (NULL != buf) {
77+
opal_accelerator.host_register(MCA_ACCELERATOR_NO_DEVICE_ID, (void *)buf, realsize);
7578
}
7679

7780
*size = realsize;

0 commit comments

Comments
 (0)