Skip to content

Commit

Permalink
Cleanup and minor fixes. Activity awareness complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Schanen committed Mar 7, 2014
1 parent e6a12ac commit 38d9e5e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 40 deletions.
2 changes: 1 addition & 1 deletion include/ampi_tape.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Sets the chunk size of the AMPI tape. When the tape exceeds this size, a new
* chunk is allocated.
*/
#define AMPI_CHUNK_SIZE 5000
#define AMPI_CHUNK_SIZE 500000

/**
* @{
Expand Down
3 changes: 1 addition & 2 deletions interfaces/dco/ampi_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {
//forward declare von AMPI

#ifndef DCO_AMPI
void ampi_interpret_tape(long int idx) {}
//void ampi_interpret_tape(long int idx) {}
#endif


Expand Down Expand Up @@ -73,7 +73,6 @@ extern "C" {
//todo: insert an external function handler!!!
global_tape->register_external_function(&ampi_tape_wrapper, new AMPI_data(*i));
//this will call ampi_interpret_tape
std::cout << "i: " << *i << endl;
}

void ampi_create_dummies(void *buf, int *size) {
Expand Down
18 changes: 6 additions & 12 deletions src/ampi.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ int AMPI_Isend_f(double *buf, int count, MPI_Datatype datatype, int dest, int ta

int AMPI_Isend_b(double *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request) {
int i = 0;
/*printf("Send_b request ptr: %p\n", request->request);*/
if(!request->aw) {
MPI_Wait(request->request, MPI_STATUS_IGNORE);
for(i = 0 ; i < request->size ; i++) {
Expand Down Expand Up @@ -148,7 +147,6 @@ int AMPI_Irecv_f(double *buf, int count, MPI_Datatype datatype, int dest, int ta

int AMPI_Irecv_b(double *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request) {
int i = 0;
/*printf("Recv_b request ptr: %p\n", request->request);*/
if(!request->aw) {
MPI_Wait(request->request, &request->status);
for(i = 0 ; i < request->size ; i++) {
Expand Down Expand Up @@ -177,7 +175,6 @@ int AMPI_Wait_b(AMPI_Request *request, MPI_Status * status) {
#ifdef DEBUG
int i=0;
#endif
/*printf("Wait_b request ptr: %p\n", request->request);*/
if(request->oc == AMPI_IS) {
return MPI_Irecv(request->a, request->size, MPI_DOUBLE, request->dest, request->tag, request->comm, request->request);
}
Expand Down Expand Up @@ -467,7 +464,6 @@ int AMPI_Allreduce_b(double *sendbuf, double *recvbuf, int count, MPI_Datatype d
double *r = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
printf("AMPI_Allreduce start\n");
#ifdef DEBUG
printf("AMPI_Allreduce_b count: %d\n",count);
for(i=0 ; i<count ; i++) {
Expand Down Expand Up @@ -511,9 +507,9 @@ int AMPI_Allreduce_b(double *sendbuf, double *recvbuf, int count, MPI_Datatype d
s_d[i] = recvbuf[i];
}
if(op == MPI_PROD) {
/*#ifdef DEBUG*/
#ifdef DEBUG
printf("AMPI_Allreduce_b MPI_PROD\n");
/*#endif*/
#endif
for(i=0 ; i<count ; i=i+1) {
if(r[i]*s_d[i] == 0.0){
sendbuf[i]=0;
Expand All @@ -528,9 +524,9 @@ int AMPI_Allreduce_b(double *sendbuf, double *recvbuf, int count, MPI_Datatype d
}
}
if(op == MPI_SUM) {
/*#ifdef DEBUG*/
#ifdef DEBUG
printf("AMPI_Allreduce_b MPI_SUM\n");
/*#endif*/
#endif
for(i=0 ; i<count ; i=i+1) {
sendbuf[i] = s_d[i];
}
Expand All @@ -541,11 +537,10 @@ int AMPI_Allreduce_b(double *sendbuf, double *recvbuf, int count, MPI_Datatype d
}
if(op == MPI_MIN || op == MPI_MAX) {
minmaxbuf_tmp = (double*) malloc(sizeof(double)*count);
/*#ifdef DEBUG*/
#ifdef DEBUG
printf("AMPI_Allreduce_b MPI_MIN or MPI_MAX start \n");
/*#endif*/
#endif
MPI_Allreduce(recvbuf, minmaxbuf_tmp, count, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
printf("AMPI_Allreduce_b MPI_MIN or MPI_MAX end\n");
for(i=count-1;i>=0;i--) {
idx=(int)AMPI_pop(&ampi_reduce_stack);
if(myid==idx) {
Expand All @@ -569,7 +564,6 @@ int AMPI_Allreduce_b(double *sendbuf, double *recvbuf, int count, MPI_Datatype d
}
printf("\n");
#endif
printf("AMPI_Allreduce end\n");
return MPI_SUCCESS;
}

Expand Down
28 changes: 3 additions & 25 deletions src/ampi_tape.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ int AMPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MP
for(i=0;i<count;i=i+1) {
ampi_tape[ampi_vac+i].oc = MPI_DUMMY;
ampi_get_val(buf,&i,&tmp[i]);
/*printf("MPI_DUMMY IDX: %d\n", tmp_int64);*/
ampi_get_idx(buf, &i, &ampi_tape[ampi_vac+i].idx);
}

Expand Down Expand Up @@ -777,7 +776,6 @@ int AMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int source, int
ampi_tape[ampi_vac].tag = tag;
HASH_ADD_PTR(AMPI_ht,key,ht_el);
ampi_vac=ampi_vac+1;
printf("Hallo\n");
return 0;
}
int AMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *mpi_request) {
Expand All @@ -787,7 +785,6 @@ int AMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dest, int ta
if(datatype!=AMPI_DOUBLE) {
return MPI_Send_init(buf, count, datatype, dest, tag, comm, mpi_request);
}
printf("Hallo\n");
ampi_check_tape_size(1);
AMPI_Request *request=(AMPI_Request*) malloc(sizeof(AMPI_Request));
AMPI_ht_el *ht_el=(AMPI_ht_el*) malloc(sizeof(AMPI_ht_el));
Expand Down Expand Up @@ -836,7 +833,7 @@ int AMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype, int dest,
ampi_tape[ampi_vac+count].comm = comm;
ampi_tape[ampi_vac+count].tag = sendtag;

long int new_vac = ampi_vac+count;
long int new_vac = ampi_vac+count+1;

ampi_create_dummies(buf, &count);
ampi_create_tape_entry(&new_vac);
Expand Down Expand Up @@ -870,7 +867,6 @@ int AMPI_Start(MPI_Request *mpi_request) {
#ifdef AMPI_COUNT_COMMS
ampi_comm_count=ampi_comm_count+1;
#endif
printf("AMPI_Start\n");
AMPI_ht_el *ht_req=NULL;
int ret=0;
long int va=0;
Expand Down Expand Up @@ -930,10 +926,10 @@ void ampi_interpret_tape(long int idx){
/*ampi_vac=ampi_vac-1;*/
/*i=ampi_vac;*/
i=idx;
/*#ifdef DEBUG*/
#ifdef DEBUG
printf("AMPI_TAPE Interpreter OC: %d\n", ampi_tape[i].oc);
printf("--------------------------------START\n");
/*#endif*/
#endif
switch(ampi_tape[i].oc){
case SEND : {
tmp_d = (double*) malloc(sizeof(double)*ampi_tape[i].arg[0]);
Expand Down Expand Up @@ -1176,8 +1172,6 @@ void ampi_interpret_tape(long int idx){
break;
}
case SENDRECVREPLACE : {
/*two entries for sendrecvreplace, decrease tape index*/
/*i=i-1;ampi_vac=ampi_vac-1;*/
tmp_d = (double*) malloc(sizeof(double)*ampi_tape[i].arg[0]);
/*take adjoints out of the tape in the send buffer*/
#pragma omp parallel for private(tmp_entry)
Expand All @@ -1195,7 +1189,6 @@ void ampi_interpret_tape(long int idx){

/*two entries for sendrecvreplace, decrease tape index*/
i=i-1;
/*ampi_vac=ampi_vac-1;*/
#pragma omp parallel for private(tmp_entry)
for(j=0;j<ampi_tape[i].arg[0];j=j+1) {
tmp_entry=&ampi_tape[i-ampi_tape[i].arg[0]+j];
Expand All @@ -1213,23 +1206,8 @@ void ampi_interpret_tape(long int idx){
}

}
printf("-------------------------------- END\n");
}
void ampi_reset_entry(long int idx){
/*int j=0;*/
/*double *tmp_d;*/
/*double *tmp_d_recv;*/
/*double *tmp_d_send;*/
/*long int i=ampi_vac;*/
/*ampi_tape_entry *tmp_entry;*/
/*MPI_Comm comm;*/
/*MPI_Op op = MPI_SUM;*/
/*comm = MPI_COMM_WORLD;*/
/*MPI_Status status;*/
/*ampi_vac=ampi_vac-1;*/
/*while(ampi_tape[ampi_vac].oc == MPI_DUMMY)*/
/*ampi_vac=ampi_vac-1;*/
/*printf("ampi_vac,idx: %lu,%lu\n", ampi_vac, idx);*/
ampi_vac=idx;
}
void ampi_print_tape() {
Expand Down

0 comments on commit 38d9e5e

Please sign in to comment.