@@ -29,11 +29,11 @@ thread_work(
29
29
ers = "qv_scope_group_rank failed" ;
30
30
ctu_panic ("%s (rc=%s)" , ers , qv_strerr (rc ));
31
31
}
32
-
32
+
33
33
ctu_scope_report (scope , "thread_scope_in_thread_routine" );
34
34
ctu_emit_task_bind (scope );
35
-
36
- fprintf ( stdout , "[%d] ============ Thread %d splitting in two pieces\n" , tid , rank );
35
+
36
+ printf ( "[%d] ============ Thread %d splitting in two pieces\n" , tid , rank );
37
37
qv_scope_t * pthread_subscope = NULL ;
38
38
rc = qv_scope_split (scope , 2 , rank , & pthread_subscope );
39
39
if (rc != QV_SUCCESS ) {
@@ -44,7 +44,7 @@ thread_work(
44
44
ctu_scope_report (pthread_subscope , "thread_subscope" );
45
45
ctu_emit_task_bind (pthread_subscope );
46
46
47
-
47
+
48
48
rc = qv_scope_free (pthread_subscope );
49
49
if (rc != QV_SUCCESS ) {
50
50
ers = "qv_scope_free failed" ;
@@ -73,6 +73,11 @@ main(void)
73
73
ers = "MPI_Comm_size() failed" ;
74
74
ctu_panic ("%s (rc=%d)" , ers , rc );
75
75
}
76
+ // TODO: As Edgar pointed out, this will work only in the single process
77
+ // case. The mpi_scope needs to be split to get a new single MPI scope.
78
+ if (wsize != 1 ) {
79
+ ctu_panic ("!!! This test works only with one MPI process!" );
80
+ }
76
81
77
82
rc = MPI_Comm_rank (comm , & wrank );
78
83
if (rc != MPI_SUCCESS ) {
@@ -100,46 +105,41 @@ main(void)
100
105
101
106
ctu_scope_report (mpi_scope , "mpi_scope" );
102
107
ctu_emit_task_bind (mpi_scope );
103
-
104
- //As Edgar pointed out, this will work only in the
105
- //single process case.
106
- //The mpi_scope need to be plsit in order to get
107
- //a new mpi_single_process_scope
108
-
109
108
//
110
109
// Test qv_pthread_scope_split
111
110
//
112
111
int npieces = 2 ;
113
112
int nthreads = ncores ;
114
113
int stride = 1 ;
115
114
int colors [nthreads ];
116
-
117
- printf ("[%d] Testing thread_scope_split (nthreads=%i, npieces=%i)\n" , tid , nthreads , npieces );
118
-
115
+
116
+ printf (
117
+ "[%d] Testing thread_scope_split (nthreads=%d, npieces=%d)\n" ,
118
+ tid , nthreads , npieces
119
+ );
120
+
119
121
for (int i = 0 ; i < nthreads ; i ++ ) {
120
122
colors [i ] = i % npieces ;
121
123
}
122
124
123
- fprintf ( stdout , "Array values : " );
125
+ printf ( "Manual values: " );
124
126
for (int i = 0 ; i < nthreads ; i ++ ) {
125
- fprintf ( stdout , "val[%i]: %i |" ,i ,colors [i ]);
127
+ printf ( "val[%i]:%i | " ,i ,colors [i ]);
126
128
}
127
- fprintf (stdout ,"\n" );
128
-
129
+ printf ("\n" );
129
130
130
131
rc = qv_pthread_colors_fill (colors , nthreads , QV_POLICY_PACKED , stride , npieces );
131
132
if (rc != QV_SUCCESS ) {
132
133
ers = "qv_pthread_colors_fill() failed" ;
133
134
ctu_panic ("%s (rc=%s)" , ers , qv_strerr (rc ));
134
135
}
135
136
136
- fprintf (stdout ,"Array values : " );
137
+ fprintf (stdout ,"Filled values: " );
137
138
for (int i = 0 ; i < nthreads ; i ++ ) {
138
- fprintf (stdout ,"val[%i]: %i |" ,i ,colors [i ]);
139
+ fprintf (stdout ,"val[%i]:%i | " ,i ,colors [i ]);
139
140
}
140
141
fprintf (stdout ,"\n" );
141
-
142
-
142
+
143
143
qv_scope_t * * th_scopes = NULL ;
144
144
rc = qv_pthread_scope_split (
145
145
mpi_scope , npieces , colors , nthreads , & th_scopes
@@ -189,7 +189,7 @@ main(void)
189
189
190
190
printf ("[%d] Testing thread_scope_split_at (nthreads=%i)\n" , tid , nthreads );
191
191
192
- int colors2 [nthreads ];
192
+ int colors2 [nthreads ];
193
193
for (int i = 0 ; i < nthreads ; i ++ ) {
194
194
colors2 [i ] = i % ncores ;
195
195
}
@@ -200,7 +200,7 @@ main(void)
200
200
}
201
201
fprintf (stdout ,"\n" );
202
202
203
-
203
+
204
204
rc = qv_pthread_colors_fill (colors2 , nthreads , QV_POLICY_PACKED , stride , ncores );
205
205
if (rc != QV_SUCCESS ) {
206
206
ers = "qv_pthread_colors_fill() failed" ;
0 commit comments