Skip to content

Commit d996f52

Browse files
matcabralaravindksg
authored andcommitted
MTL OFI: Add support for mem_tag_format
OFI providers may reserve some of the upper bits of the tag for internal usage and expose it using mem_tag_format. Check for that and adjust communicator bits as needed. Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@intel.com>
1 parent 7d6fd34 commit d996f52

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

ompi/mca/mtl/ofi/help-mtl-ofi.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- text -*-
22
#
3-
# Copyright (c) 2013-2017 Intel, Inc. All rights reserved
3+
# Copyright (c) 2013-2018 Intel, Inc. All rights reserved
44
#
55
# Copyright (c) 2017 Cisco Systems, Inc. All rights reserved
66
# $COPYRIGHT$
@@ -16,3 +16,11 @@ unusual; your job may behave unpredictably (and/or abort) after this.
1616
Local host: %s
1717
Location: %s:%d
1818
Error: %s (%zd)
19+
#
20+
[Not enough bits for CID]
21+
OFI provider "%s" does not have enough free bits in its tag to fit the MPI
22+
Communicator ID. See the mem_tag_format of the provider by running:
23+
fi_info -v -p %s
24+
25+
Local host: %s
26+
Location: %s:%d

ompi/mca/mtl/ofi/mtl_ofi_component.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ ompi_mtl_ofi_check_fi_remote_cq_data(int fi_version,
387387
}
388388

389389
static void
390-
ompi_mtl_ofi_define_tag_mode(int ofi_tag_mode) {
390+
ompi_mtl_ofi_define_tag_mode(int ofi_tag_mode, int *bits_for_cid) {
391391
switch (ofi_tag_mode) {
392392
case MTL_OFI_TAG_1:
393-
ompi_mtl_ofi.base.mtl_max_contextid = (int)((1ULL << MTL_OFI_CID_BIT_COUNT_1 ) - 1);
393+
*bits_for_cid = (int) MTL_OFI_CID_BIT_COUNT_1;
394394
ompi_mtl_ofi.base.mtl_max_tag = (int)((1ULL << (MTL_OFI_TAG_BIT_COUNT_1 - 1)) - 1);
395395

396396
ompi_mtl_ofi.source_rank_tag_mask = MTL_OFI_SOURCE_TAG_MASK_1;
@@ -405,7 +405,7 @@ ompi_mtl_ofi_define_tag_mode(int ofi_tag_mode) {
405405
ompi_mtl_ofi.sync_proto_mask = MTL_OFI_PROTO_MASK_1;
406406
break;
407407
case MTL_OFI_TAG_2:
408-
ompi_mtl_ofi.base.mtl_max_contextid = (int)((1ULL << MTL_OFI_CID_BIT_COUNT_2 ) - 1);
408+
*bits_for_cid = (int) MTL_OFI_CID_BIT_COUNT_2;
409409
ompi_mtl_ofi.base.mtl_max_tag = (int)((1ULL << (MTL_OFI_TAG_BIT_COUNT_2 - 1)) - 1);
410410

411411
ompi_mtl_ofi.source_rank_tag_mask = MTL_OFI_SOURCE_TAG_MASK_2;
@@ -420,7 +420,7 @@ ompi_mtl_ofi_define_tag_mode(int ofi_tag_mode) {
420420
ompi_mtl_ofi.sync_proto_mask = MTL_OFI_PROTO_MASK_2;
421421
break;
422422
default: /* use FI_REMOTE_CQ_DATA */
423-
ompi_mtl_ofi.base.mtl_max_contextid = (int)((1ULL << MTL_OFI_CID_BIT_COUNT_DATA ) - 1);
423+
*bits_for_cid = (int) MTL_OFI_CID_BIT_COUNT_DATA;
424424
ompi_mtl_ofi.base.mtl_max_tag = (int)((1ULL << (MTL_OFI_TAG_BIT_COUNT_DATA - 1)) - 1);
425425

426426
ompi_mtl_ofi.mpi_tag_mask = MTL_OFI_TAG_MASK_DATA;
@@ -444,6 +444,8 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
444444
struct fi_av_attr av_attr = {0};
445445
char ep_name[FI_NAME_MAX] = {0};
446446
size_t namelen;
447+
int ofi_tag_leading_zeros;
448+
int ofi_tag_bits_for_cid;
447449

448450
/**
449451
* Hints to filter providers
@@ -558,7 +560,7 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
558560
ompi_mtl_ofi.fi_cq_data = false;
559561
if (MTL_OFI_TAG_AUTO == ofi_tag_mode) {
560562
/* Fallback to MTL_OFI_TAG_1 */
561-
ompi_mtl_ofi_define_tag_mode(MTL_OFI_TAG_1);
563+
ompi_mtl_ofi_define_tag_mode(MTL_OFI_TAG_1, &ofi_tag_bits_for_cid);
562564
} else { /* MTL_OFI_TAG_FULL */
563565
opal_output_verbose(1, ompi_mtl_base_framework.framework_output,
564566
"%s:%d: OFI provider %s does not support FI_REMOTE_CQ_DATA\n",
@@ -569,13 +571,37 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
569571
/* Use FI_REMTOTE_CQ_DATA */
570572
ompi_mtl_ofi.fi_cq_data = true;
571573
prov = prov_cq_data;
572-
ompi_mtl_ofi_define_tag_mode(MTL_OFI_TAG_FULL);
574+
ompi_mtl_ofi_define_tag_mode(MTL_OFI_TAG_FULL, &ofi_tag_bits_for_cid);
573575
}
574576
} else { /* MTL_OFI_TAG_1 or MTL_OFI_TAG_2 */
575577
ompi_mtl_ofi.fi_cq_data = false;
576-
ompi_mtl_ofi_define_tag_mode(ofi_tag_mode);
578+
ompi_mtl_ofi_define_tag_mode(ofi_tag_mode, &ofi_tag_bits_for_cid);
577579
}
578580

581+
/**
582+
* Check for potential bits in the OFI tag that providers may be reserving
583+
* for internal usage (see mem_tag_format in fi_endpoint man page).
584+
*/
585+
586+
ofi_tag_leading_zeros = 0;
587+
while (!((prov->ep_attr->mem_tag_format << ofi_tag_leading_zeros++) &
588+
(uint64_t) MTL_OFI_HIGHEST_TAG_BIT) &&
589+
/* Do not keep looping if the provider does not support enough bits */
590+
(ofi_tag_bits_for_cid >= MTL_OFI_MINIMUM_CID_BITS)){
591+
ofi_tag_bits_for_cid--;
592+
}
593+
594+
if (ofi_tag_bits_for_cid < MTL_OFI_MINIMUM_CID_BITS) {
595+
opal_show_help("help-mtl-ofi.txt", "Not enough bits for CID", true,
596+
prov->fabric_attr->prov_name,
597+
prov->fabric_attr->prov_name,
598+
ompi_process_info.nodename, __FILE__, __LINE__);
599+
goto error;
600+
}
601+
602+
/* Update the maximum supported Communicator ID */
603+
ompi_mtl_ofi.base.mtl_max_contextid = (int)((1ULL << ofi_tag_bits_for_cid) - 1);
604+
579605
/**
580606
* Open fabric
581607
* The getinfo struct returns a fabric attribute struct that can be used to

ompi/mca/mtl/ofi/mtl_ofi_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ typedef struct mca_mtl_ofi_component_t {
8888
* More details of the tags are in the README file (mtl_ofi_tag_mode).
8989
*/
9090

91+
#define MTL_OFI_MINIMUM_CID_BITS (8)
92+
9193
/* Support FI_REMOTE_CQ_DATA, send the source rank in the CQ data (4 Bytes is the minimum)
9294
* 01234567 01234567 01234567 012345 67 01234567 01234567 01234567 01234567
9395
* | |
9496
* context_id |prot| message tag
9597
*/
9698
#define MTL_OFI_PROTO_BIT_COUNT (2)
99+
#define MTL_OFI_HIGHEST_TAG_BIT (0x8000000000000000ULL)
97100

98101
#define MTL_OFI_CID_MASK_DATA (0xFFFFFFFC00000000ULL)
99102
#define MTL_OFI_CID_BIT_COUNT_DATA (30)

0 commit comments

Comments
 (0)