A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
try to fix some compilation erros
[simgrid.git]
/
src
/
smpi
/
colls
/
alltoall-3dmesh.c
diff --git
a/src/smpi/colls/alltoall-3dmesh.c
b/src/smpi/colls/alltoall-3dmesh.c
index
ed734e5
..
81b1ecd
100644
(file)
--- a/
src/smpi/colls/alltoall-3dmesh.c
+++ b/
src/smpi/colls/alltoall-3dmesh.c
@@
-1,4
+1,10
@@
-#include "colls.h"
+/* Copyright (c) 2013-2014. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "colls_private.h"
#include <math.h>
/*****************************************************************************
#include <math.h>
/*****************************************************************************
@@
-24,7
+30,7
@@
* Auther: Ahmad Faraj
****************************************************************************/
* Auther: Ahmad Faraj
****************************************************************************/
-int alltoall_check_is_3dmesh(int num, int *i, int *j, int *k)
+
static
int alltoall_check_is_3dmesh(int num, int *i, int *j, int *k)
{
int x, max = num / 3;
x = cbrt(num);
{
int x, max = num / 3;
x = cbrt(num);
@@
-43,24
+49,23
@@
int alltoall_check_is_3dmesh(int num, int *i, int *j, int *k)
int smpi_coll_tuned_alltoall_3dmesh(void *send_buff, int send_count,
MPI_Datatype send_type,
void *recv_buff, int recv_count,
int smpi_coll_tuned_alltoall_3dmesh(void *send_buff, int send_count,
MPI_Datatype send_type,
void *recv_buff, int recv_count,
- MPI_Datatype recv_type,
- MPI_Comm comm)
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Request *reqs, *req_ptr;
MPI_Aint extent;
MPI_Status status, *statuses;
int i, j, src, dst, rank, num_procs, num_reqs, X, Y, Z, block_size, count;
int my_z, two_dsize, my_row_base, my_col_base, my_z_base, src_row_base;
{
MPI_Request *reqs, *req_ptr;
MPI_Aint extent;
MPI_Status status, *statuses;
int i, j, src, dst, rank, num_procs, num_reqs, X, Y, Z, block_size, count;
int my_z, two_dsize, my_row_base, my_col_base, my_z_base, src_row_base;
- int src_z_base, send_offset, recv_offset, tag =
1, failure = 0, success = 1
;
+ int src_z_base, send_offset, recv_offset, tag =
COLL_TAG_ALLTOALL
;
char *tmp_buff1, *tmp_buff2;
char *tmp_buff1, *tmp_buff2;
-
MPI_Comm_rank(comm, &rank
);
-
MPI_Comm_size(comm, &num_procs
);
-
MPI_Type_extent(send_type, &extent
);
+
rank = smpi_comm_rank(comm
);
+
num_procs = smpi_comm_size(comm
);
+
extent = smpi_datatype_get_extent(send_type
);
if (!alltoall_check_is_3dmesh(num_procs, &X, &Y, &Z))
if (!alltoall_check_is_3dmesh(num_procs, &X, &Y, &Z))
- return
failure
;
+ return
MPI_ERR_OTHER
;
num_reqs = X;
if (Y > X)
num_reqs = X;
if (Y > X)
@@
-77,33
+82,17
@@
int smpi_coll_tuned_alltoall_3dmesh(void *send_buff, int send_count,
block_size = extent * send_count;
block_size = extent * send_count;
- tmp_buff1 = (char *) malloc(block_size * num_procs * two_dsize);
- if (!tmp_buff1) {
- printf("alltoall-3Dmesh:97: cannot allocate memory\n");
- MPI_Finalize();
- exit(failure);
- }
-
- tmp_buff2 = (char *) malloc(block_size * two_dsize);
- if (!tmp_buff2) {
- printf("alltoall-3Dmesh:105: cannot allocate memory\n");
- MPI_Finalize();
- exit(failure);
- }
+ tmp_buff1 = (char *) smpi_get_tmp_sendbuffer(block_size * num_procs * two_dsize);
+ tmp_buff2 = (char *) smpi_get_tmp_recvbuffer(block_size * two_dsize);
- statuses = (MPI_Status *) malloc(num_reqs * sizeof(MPI_Status));
- reqs = (MPI_Request *) malloc(num_reqs * sizeof(MPI_Request));
- if (!reqs) {
- printf("alltoall-3Dmesh:113: cannot allocate memory\n");
- MPI_Finalize();
- exit(failure);
- }
+ statuses = (MPI_Status *) xbt_malloc(num_reqs * sizeof(MPI_Status));
+ reqs = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request));
req_ptr = reqs;
req_ptr = reqs;
-
send_offset =
recv_offset = (rank % two_dsize) * block_size * num_procs;
+ recv_offset = (rank % two_dsize) * block_size * num_procs;
-
MPI_S
endrecv(send_buff, send_count * num_procs, send_type, rank, tag,
+
smpi_mpi_s
endrecv(send_buff, send_count * num_procs, send_type, rank, tag,
tmp_buff1 + recv_offset, num_procs * recv_count,
recv_type, rank, tag, comm, &status);
tmp_buff1 + recv_offset, num_procs * recv_count,
recv_type, rank, tag, comm, &status);
@@
-114,18
+103,17
@@
int smpi_coll_tuned_alltoall_3dmesh(void *send_buff, int send_count,
if (src == rank)
continue;
recv_offset = (src % two_dsize) * block_size * num_procs;
if (src == rank)
continue;
recv_offset = (src % two_dsize) * block_size * num_procs;
- MPI_Irecv(tmp_buff1 + recv_offset, count, recv_type, src, tag, comm,
- req_ptr++);
+ *(req_ptr++) = smpi_mpi_irecv(tmp_buff1 + recv_offset, count, recv_type, src, tag, comm);
}
for (i = 0; i < Y; i++) {
dst = i + my_row_base;
if (dst == rank)
continue;
}
for (i = 0; i < Y; i++) {
dst = i + my_row_base;
if (dst == rank)
continue;
-
MPI_S
end(send_buff, count, send_type, dst, tag, comm);
+
smpi_mpi_s
end(send_buff, count, send_type, dst, tag, comm);
}
}
-
MPI_W
aitall(Y - 1, reqs, statuses);
+
smpi_mpi_w
aitall(Y - 1, reqs, statuses);
req_ptr = reqs;
req_ptr = reqs;
@@
-137,8
+125,8
@@
int smpi_coll_tuned_alltoall_3dmesh(void *send_buff, int send_count,
src_row_base = (src / X) * X;
recv_offset = (src_row_base % two_dsize) * block_size * num_procs;
src_row_base = (src / X) * X;
recv_offset = (src_row_base % two_dsize) * block_size * num_procs;
-
MPI_I
recv(tmp_buff1 + recv_offset, recv_count * num_procs * Y,
- recv_type, src, tag, comm
, req_ptr++
);
+
*(req_ptr++) = smpi_mpi_i
recv(tmp_buff1 + recv_offset, recv_count * num_procs * Y,
+ recv_type, src, tag, comm);
}
send_offset = (my_row_base % two_dsize) * block_size * num_procs;
}
send_offset = (my_row_base % two_dsize) * block_size * num_procs;
@@
-146,19
+134,19
@@
int smpi_coll_tuned_alltoall_3dmesh(void *send_buff, int send_count,
dst = (i * Y + my_col_base);
if (dst == rank)
continue;
dst = (i * Y + my_col_base);
if (dst == rank)
continue;
-
MPI_S
end(tmp_buff1 + send_offset, send_count * num_procs * Y, send_type,
+
smpi_mpi_s
end(tmp_buff1 + send_offset, send_count * num_procs * Y, send_type,
dst, tag, comm);
}
dst, tag, comm);
}
-
MPI_W
aitall(X - 1, reqs, statuses);
+
smpi_mpi_w
aitall(X - 1, reqs, statuses);
req_ptr = reqs;
for (i = 0; i < two_dsize; i++) {
send_offset = (rank * block_size) + (i * block_size * num_procs);
recv_offset = (my_z_base * block_size) + (i * block_size);
req_ptr = reqs;
for (i = 0; i < two_dsize; i++) {
send_offset = (rank * block_size) + (i * block_size * num_procs);
recv_offset = (my_z_base * block_size) + (i * block_size);
-
MPI_S
endrecv(tmp_buff1 + send_offset, send_count, send_type, rank, tag,
-
recv_buff + recv_offset, recv_count, recv_type, rank, tag
,
- comm, &status);
+
smpi_mpi_s
endrecv(tmp_buff1 + send_offset, send_count, send_type, rank, tag,
+
(char *) recv_buff + recv_offset, recv_count, recv_type
,
+
rank, tag,
comm, &status);
}
for (i = 1; i < Z; i++) {
}
for (i = 1; i < Z; i++) {
@@
-167,8
+155,8
@@
int smpi_coll_tuned_alltoall_3dmesh(void *send_buff, int send_count,
recv_offset = (src_z_base * block_size);
recv_offset = (src_z_base * block_size);
-
MPI_Irecv(recv_buff + recv_offset, recv_count * two_dsize, recv_typ
e,
-
src, tag, comm, req_ptr++
);
+
*(req_ptr++) = smpi_mpi_irecv((char *) recv_buff + recv_offset, recv_count * two_dsiz
e,
+
recv_type, src, tag, comm
);
}
for (i = 1; i < Z; i++) {
}
for (i = 1; i < Z; i++) {
@@
-177,22
+165,22
@@
int smpi_coll_tuned_alltoall_3dmesh(void *send_buff, int send_count,
recv_offset = 0;
for (j = 0; j < two_dsize; j++) {
send_offset = (dst + j * num_procs) * block_size;
recv_offset = 0;
for (j = 0; j < two_dsize; j++) {
send_offset = (dst + j * num_procs) * block_size;
-
MPI_S
endrecv(tmp_buff1 + send_offset, send_count, send_type,
+
smpi_mpi_s
endrecv(tmp_buff1 + send_offset, send_count, send_type,
rank, tag, tmp_buff2 + recv_offset, recv_count,
recv_type, rank, tag, comm, &status);
recv_offset += block_size;
}
rank, tag, tmp_buff2 + recv_offset, recv_count,
recv_type, rank, tag, comm, &status);
recv_offset += block_size;
}
-
MPI_S
end(tmp_buff2, send_count * two_dsize, send_type, dst, tag, comm);
+
smpi_mpi_s
end(tmp_buff2, send_count * two_dsize, send_type, dst, tag, comm);
}
}
-
MPI_W
aitall(Z - 1, reqs, statuses);
+
smpi_mpi_w
aitall(Z - 1, reqs, statuses);
free(reqs);
free(statuses);
free(reqs);
free(statuses);
-
free
(tmp_buff1);
-
free
(tmp_buff2);
- return
success
;
+
smpi_free_tmp_buffer
(tmp_buff1);
+
smpi_free_tmp_buffer
(tmp_buff2);
+ return
MPI_SUCCESS
;
}
}