To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 4a515c33 authored by ahuegli's avatar ahuegli

Merge branch 'master' of gitlab.ethz.ch:ahuegli/exercise

parents 1e4e1bea 0253727e
......@@ -17,7 +17,6 @@ void WaveEquation::pack_all() {
// of each pack reduce to the numbers 0,1,2,3,4,5.
// ********************************************************************************
#pragma omp parallel {
int array_of_sizes[3] = {N + 2, N + 2, N + 2};
int nloc = N / threads_per_dim;
int p = threads_per_dim;
......@@ -29,39 +28,39 @@ void WaveEquation::pack_all() {
int pid = 0 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
int array_of_subsizes[3] = {1, nloc, nloc};
int array_of_starts[3] = {N, 1+t1*nloc, 1+t2*nloc};
pack_face(pack[0], array_of_sizes, array_of_subsizes, array_of_starts);
pack_face(pack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t0 == 0) {
int pid = 1 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
int array_of_subsizes[3] = {1, nloc, nloc};
int array_of_starts[3] = {1+t0*nloc, 1+t1*nloc, 1+t2*nloc};
pack_face(pack[1], array_of_sizes, array_of_subsizes, array_of_starts);
pack_face(pack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t1 == p - 1) {
int pid = 2 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t2;
int array_of_subsizes[3] = {nloc, 1, nloc};
int array_of_starts[3] = {1+t0*nloc, N, 1+t2*nloc};
pack_face(pack[2], array_of_sizes, array_of_subsizes, array_of_starts);
pack_face(pack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t1 == 0) {
int pid = 3 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t2;
int array_of_subsizes[3] = {nloc, 1, nloc};
int array_of_starts[3] = {1+t0*nloc, 1+t1*nloc, 1+t2*nloc};
pack_face(pack[3], array_of_sizes, array_of_subsizes, array_of_starts);
pack_face(pack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t2 == p - 1) {
int pid = 4 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t1;
int array_of_subsizes[3] = {nloc, nloc, 1};
int array_of_starts[3] = {1+t0*nloc, 1+t1*nloc, N};
pack_face(pack[4], array_of_sizes, array_of_subsizes, array_of_starts);
pack_face(pack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t2 == 0) {
int pid = 5 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t1;
int array_of_subsizes[3] = {nloc, nloc, 1};
int array_of_starts[3] = {1+t0*nloc, 1+t1*nloc, 1+t2*nloc};
pack_face(pack[5], array_of_sizes, array_of_subsizes, array_of_starts);
pack_face(pack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
}
// You will need to remove this part, when you fill the if statements above
/*{
int array_of_subsizes[3] = {1, N, N};
......@@ -113,8 +112,7 @@ void WaveEquation::unpack_all() {
// the id's of each unpack reduce to the numbers 0,1,2,3,4,5.
// ********************************************************************************
#pragma omp parallel
{
int array_of_sizes[3] = {N + 2, N + 2, N + 2};
int nloc = N / threads_per_dim;
int p = threads_per_dim;
......@@ -126,39 +124,39 @@ void WaveEquation::unpack_all() {
int pid = 0 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
int array_of_subsizes[3] = {1, nloc, nloc};
int array_of_starts[3] = {0, 1+t1*nloc, 1+t2*nloc};
unpack_face(unpack[0], array_of_sizes, array_of_subsizes, array_of_starts);
unpack_face(unpack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t0 == p - 1) {
int pid = 1 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
int array_of_subsizes[3] = {1, nloc, nloc};
int array_of_starts[3] = {N + 1, 1+t1*nloc, 1+t2*nloc};
unpack_face(unpack[1], array_of_sizes, array_of_subsizes, array_of_starts);
unpack_face(unpack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t1 == 0) {
int pid = 2 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t2;
int array_of_subsizes[3] = {nloc, 1, nloc};
int array_of_starts[3] = {1+t0*nloc, 0, 1+t2*nloc};
unpack_face(unpack[2], array_of_sizes, array_of_subsizes, array_of_starts);
unpack_face(unpack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t1 == p - 1) {
int pid = 3 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t2;
int array_of_subsizes[3] = {nloc, 1, nloc};
int array_of_starts[3] = {1+t0*nloc, N + 1, 1+t2*nloc};
unpack_face(unpack[3], array_of_sizes, array_of_subsizes, array_of_starts);
unpack_face(unpack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t2 == 0) {
int pid = 4 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t1;
int array_of_subsizes[3] = {nloc, nloc, 1};
int array_of_starts[3] = {1+t0*nloc, 1+t1*nloc, 0};
unpack_face(unpack[4], array_of_sizes, array_of_subsizes, array_of_starts);
unpack_face(unpack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
if (t2 == p - 1) {
int pid = 5 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t1;
int array_of_subsizes[3] = {nloc, nloc, 1};
int array_of_starts[3] = {1+t0*nloc, 1+t1*nloc, N + 1};
unpack_face(unpack[5], array_of_sizes, array_of_subsizes, array_of_starts);
unpack_face(unpack[pid], array_of_sizes, array_of_subsizes, array_of_starts);
}
}
// You will need to remove this part, when you fill the if statements above
/*{
int array_of_subsizes[3] = {1, N, N};
......@@ -245,45 +243,49 @@ void WaveEquation::run(double t_end) {
std::vector<MPI_Request> local_request;
if (t0 == 0) {
local_request.resize(local_request.size() + 2);
pid_recv =
0 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
pid_send =
1 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
pid_recv = 0 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
pid_send = 1 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
MPI_Irecv(unpack[0], nloc*nloc, MPI_DOUBLE, rank_minus[0], 100, cart_comm,&local_request[0]);
MPI_Isend( pack[0], nloc*nloc, MPI_DOUBLE, rank_plus [0], 100, cart_comm,&local_request[1]);
}
if (t0 == p - 1) {
local_request.resize(local_request.size() + 2);
pid_recv =
1 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
pid_send =
0 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
pid_recv = 1 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
pid_send = 0 * threads_per_dim * threads_per_dim + t1 * threads_per_dim + t2;
MPI_Irecv(unpack[1], nloc*nloc, MPI_DOUBLE, rank_plus [0], 101, cart_comm,&local_request[2]);
MPI_Isend( pack[1], nloc*nloc, MPI_DOUBLE, rank_minus[0], 101, cart_comm,&local_request[3]);
}
if (t1 == 0) {
local_request.resize(local_request.size() + 2);
pid_recv = 2 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t2;
pid_send = 3 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t2;
MPI_Irecv(unpack[2], nloc*nloc, MPI_DOUBLE, rank_minus[1], 200, cart_comm,&local_request[4]);
MPI_Isend( pack[2], nloc*nloc, MPI_DOUBLE, rank_plus [1], 200, cart_comm,&local_request[5]);
}
if (t1 == p - 1) {
local_request.resize(local_request.size() + 2);
pid_recv = 3 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t2;
pid_send = 2 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t2;
MPI_Irecv(unpack[3], nloc*nloc, MPI_DOUBLE, rank_plus [1], 201, cart_comm,&local_request[6]);
MPI_Isend( pack[3], nloc*nloc, MPI_DOUBLE, rank_minus[1], 201, cart_comm,&local_request[7]);
}
if (t2 == 0) {
local_request.resize(local_request.size() + 2);
pid_recv = 4 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t1;
pid_send = 5 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t1;
MPI_Irecv(unpack[4], nloc*nloc, MPI_DOUBLE, rank_minus[2], 300, cart_comm,&local_request[8]);
MPI_Isend( pack[4], nloc*nloc, MPI_DOUBLE, rank_plus [2], 300, cart_comm,&local_request[9]);
}
if (t2 == p - 1) {
local_request.resize(local_request.size() + 2);
pid_recv = 5 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t1;
pid_send = 4 * threads_per_dim * threads_per_dim + t0 * threads_per_dim + t1;
MPI_Irecv(unpack[5], nloc*nloc, MPI_DOUBLE, rank_plus [2], 301, cart_comm,&local_request[10]);
MPI_Isend( pack[5], nloc*nloc, MPI_DOUBLE, rank_minus[2], 301, cart_comm,&local_request[11]);
}
// uncomment when you complete question 2
// MPI_Waitall(local_request.size(),
// local_request.data(),MPI_STATUSES_IGNORE);
MPI_Waitall(local_request.size(),
local_request.data(),MPI_STATUSES_IGNORE);
// ********************************************************************************
// Question 4: Some computation can be carried out before waiting for
......@@ -291,7 +293,7 @@ void WaveEquation::run(double t_end) {
// ********************************************************************************
// Remove these when you complete question 2
MPI_Request request[12];
/*MPI_Request request[12];
MPI_Irecv(unpack[0], N * N, MPI_DOUBLE, rank_minus[0], 100, cart_comm,&request[0]);
MPI_Isend( pack[0], N * N, MPI_DOUBLE, rank_plus [0], 100, cart_comm,&request[1]);
......@@ -311,7 +313,7 @@ void WaveEquation::run(double t_end) {
MPI_Isend( pack[5], N * N, MPI_DOUBLE, rank_minus[2], 301, cart_comm,&request[11]);
// Remove this when you complete question 2
MPI_Waitall(12, &request[0], MPI_STATUSES_IGNORE);
MPI_Waitall(12, &request[0], MPI_STATUSES_IGNORE);*/
unpack_all();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment