@@ -65,6 +65,21 @@ struct thread_layout {
65
65
node_thread = node_proc * proc_nthreads + proc_thread;
66
66
node_nthreads = node_nprocs * proc_nthreads;
67
67
68
+ const bool verbose = cxx::envtol (" FUNHPC_VERBOSE" , " 0" );
69
+ if (verbose)
70
+ if (proc == 0 && proc_thread == 0 ) {
71
+ std::ostringstream os;
72
+ os << " FunHPC thread layout:\n " ;
73
+ os << " proc: " << proc << " / " << nprocs << " \n " ;
74
+ os << " node_proc: " << node_proc << " / " << node_nprocs << " \n " ;
75
+ os << " node: " << node << " / " << nnodes << " \n " ;
76
+ os << " proc_thread: " << proc_thread << " / " << proc_nthreads
77
+ << " \n " ;
78
+ os << " node_thread: " << node_thread << " / " << node_nthreads
79
+ << " \n " ;
80
+ std::cout << os.str () << std::flush;
81
+ }
82
+
68
83
assert (invariant ());
69
84
}
70
85
};
@@ -96,8 +111,24 @@ struct thread_affinity {
96
111
oversubscribing
97
112
? cxx::div_floor (tl.node_thread * node_npus, tl.node_nthreads ).quot
98
113
: cxx::div_exact (tl.node_thread * node_npus, tl.node_nthreads ).quot ;
99
- assert (thread_pu + thread_npus <= node_npus);
100
114
115
+ const bool verbose = cxx::envtol (" FUNHPC_VERBOSE" , " 0" );
116
+ if (verbose)
117
+ if (tl.proc == 0 && tl.proc_thread == 0 ) {
118
+ std::ostringstream os;
119
+ os << " FunHPC thread affinity:\n " ;
120
+ os << " node_npus: " << node_npus << " \n " ;
121
+ os << " undersubscribing: " << undersubscribing << " \n " ;
122
+ os << " oversubscribing: " << oversubscribing << " \n " ;
123
+ os << " thread_pu: " << thread_pu << " / " << thread_npus << " \n " ;
124
+ std::cout << os.str () << std::flush;
125
+ }
126
+
127
+ if (!oversubscribing) {
128
+ assert (cxx::div_floor (node_npus, tl.node_nthreads ).rem == 0 );
129
+ assert (cxx::div_floor (tl.node_thread * node_npus, tl.node_nthreads ).rem ==
130
+ 0 );
131
+ }
101
132
assert (invariant ());
102
133
}
103
134
};
0 commit comments