@@ -1015,9 +1015,21 @@ static size_t test_num_am_handlers = 0;
10151015 * Wrap gasnet_attach() or gex_Segment_Attach() to validate
10161016 * the allocated segment size, alignment, etc.
10171017 */
1018+ static void _test_validate_seg_request (uintptr_t length ) {
1019+ assert_always (length > 0 );
1020+ assert_always (((uintptr_t )length ) % PAGESZ == 0 );
1021+ uintptr_t max_local = gasnet_getMaxLocalSegmentSize ();
1022+ if (length > max_local ) {
1023+ FATALERR ("Test requested a GASNet segment of size=%lu, "
1024+ "but this exceeds the currently available gasnet_getMaxLocalSegmentSize()=%lu.\n"
1025+ "You may need to adjust the memory resource limits of this system/shell, "
1026+ "otherwise adjust test parameters to reduce segment utilization requirements." ,
1027+ (unsigned long )length , (unsigned long )max_local );
1028+ }
1029+ }
10181030 #ifdef _INCLUDED_GASNET_H
1019- static int _test_attach (gasnet_handlerentry_t * table , int numentries , uintptr_t segsize , uintptr_t minheapoffset )
1020- {
1031+ static int _test_attach (gasnet_handlerentry_t * table , int numentries , uintptr_t segsize , uintptr_t minheapoffset ) {
1032+ _test_validate_seg_request ( segsize );
10211033 GASNET_Safe (gasnet_attach (table , numentries , segsize , minheapoffset ));
10221034 gex_Rank_t i ;
10231035 gasnet_seginfo_t * s = (gasnet_seginfo_t * )test_malloc (TEST_PROCS * sizeof (gasnet_seginfo_t ));
@@ -1039,8 +1051,8 @@ static size_t test_num_am_handlers = 0;
10391051 static int _test_Segment_Attach (
10401052 gex_Segment_t * segment_p ,
10411053 gex_TM_t tm ,
1042- uintptr_t length )
1043- {
1054+ uintptr_t length ) {
1055+ _test_validate_seg_request ( length );
10441056 GASNET_Safe (gex_Segment_Attach (segment_p , tm , length ));
10451057 BARRIER ();
10461058 for (gex_Rank_t i = 0 ; i < TEST_PROCS ; i ++ ) {
0 commit comments