Skip to content

Commit daf7fca

Browse files
[Libraries/MPI] OMP sample logic aligned with SYCL
1 parent 4ba57f6 commit daf7fca

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

Libraries/MPI/jacobian_solver/src/04_jacobian_device_mpi_one-sided_device_initiated_notify/mpi3_onesided_jacobian_cpu_notify.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,10 @@ int main(int argc, char *argv[])
6464
for (int k = 0; k < iterations_batch; ++k)
6565
{
6666
int i = passed_iters + k;
67-
MPI_Win prev_win = win[i % 2];
6867
MPI_Win current_win = win[(i + 1) % 2];
6968
double *in = buffs[i % 2];
7069
double *out = buffs[(1 + i) % 2];
7170

72-
/* Wait for the notification counter to reach the expected value:
73-
* here we check that communication operations issued by peers on the previous iteration are completed
74-
* and data is ready for the next iteration.
75-
*
76-
* NOTE:
77-
* To be completely standard compliant, the application should check the memory model
78-
* and call MPI_Win_sync(prev_win) in case of MPI_WIN_SEPARATE mode after the notification has been received.
79-
* Although, IntelMPI uses the MPI_WIN_UNIFIED memory model, so this call could be omitted.
80-
*/
81-
MPI_Count c = 0;
82-
MPI_Win_flush_local_all(current_win);
83-
while (c < (iter_counter_step * i)) {
84-
MPI_Win_notify_get_value(prev_win, 0, &c);
85-
}
8671

8772
/* Calculate values on the borders to initiate communications early */
8873
for (int column = 0; column < my_subarray.x_size; column++) {
@@ -119,6 +104,22 @@ int main(int argc, char *argv[])
119104
RECALCULATE_POINT(out, in, column, row, row_size);
120105
}
121106
}
107+
108+
/* Wait for the notification counter to reach the expected value:
109+
* here we check that communication operations issued by peers on the previous iteration are completed
110+
* and data is ready for the next iteration.
111+
*
112+
* NOTE:
113+
* To be completely standard compliant, the application should check the memory model
114+
* and call MPI_Win_sync(prev_win) in case of MPI_WIN_SEPARATE mode after the notification has been received.
115+
* Although, IntelMPI uses the MPI_WIN_UNIFIED memory model, so this call could be omitted.
116+
*/
117+
MPI_Count c = 0;
118+
MPI_Win_flush_all(current_win);
119+
while (c < iter_counter_step) {
120+
MPI_Win_notify_get_value(current_win, 0, &c);
121+
}
122+
MPI_Win_notify_set_value(current_win, 0, 0);
122123
}
123124

124125
/* Calculate the norm value after the given number of iterations */
@@ -154,4 +155,4 @@ int main(int argc, char *argv[])
154155
MPI_Finalize();
155156

156157
return 0;
157-
}
158+
}

Libraries/MPI/jacobian_solver/src/04_jacobian_device_mpi_one-sided_device_initiated_notify/mpi3_onesided_jacobian_gpu_omp_device_initiated_notify.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,10 @@ int main(int argc, char *argv[])
8181
for (int k = 0; k < iterations_batch; ++k)
8282
{
8383
int i = passed_iters + k;
84-
MPI_Win prev_win = win[i % 2];
8584
MPI_Win current_win = win[(i + 1) % 2];
8685
double *in = (i % 2) ? b1 : b2;
8786
double *out = ((1 + i) % 2) ? b1 : b2;
8887

89-
/* Wait for the notification counter to reach the expected value:
90-
* here we check that communication operations issued by peers on the previous iteration are completed
91-
* and data is ready for the next iteration.
92-
*
93-
* NOTE:
94-
* To be completely standard compliant, the application should check the memory model
95-
* and call MPI_Win_sync(prev_win) in case of MPI_WIN_SEPARATE mode after the notification has been received.
96-
* Although, IntelMPI uses the MPI_WIN_UNIFIED memory model, so this call could be omitted.
97-
*/
98-
MPI_Count c = 0;
99-
MPI_Win_flush_all(current_win);
100-
while (c < (iter_counter_step * i)) {
101-
MPI_Win_notify_get_value(prev_win, 0, &c);
102-
}
103-
10488
/* Start parallel loop on the device to accelerate calculation */
10589
#pragma omp parallel for
10690
/* Calculate values on the borders to initiate communications early */
@@ -141,6 +125,22 @@ int main(int argc, char *argv[])
141125
RECALCULATE_POINT(out, in, column, row, row_size);
142126
}
143127
}
128+
129+
/* Wait for the notification counter to reach the expected value:
130+
* here we check that communication operations issued by peers on the previous iteration are completed
131+
* and data is ready for the next iteration.
132+
*
133+
* NOTE:
134+
* To be completely standard compliant, the application should check the memory model
135+
* and call MPI_Win_sync(prev_win) in case of MPI_WIN_SEPARATE mode after the notification has been received.
136+
* Although, IntelMPI uses the MPI_WIN_UNIFIED memory model, so this call could be omitted.
137+
*/
138+
MPI_Count c = 0;
139+
MPI_Win_flush_all(current_win);
140+
while (c < iter_counter_step) {
141+
MPI_Win_notify_get_value(current_win, 0, &c);
142+
}
143+
MPI_Win_notify_set_value(current_win, 0, 0);
144144
}
145145
}
146146

0 commit comments

Comments
 (0)