Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only print gs_setup times if verbose is on #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions src/gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "name.h"
#include "fail.h"
#include "types.h"
#include "float.h"

#define gs_op gs_op_t /* fix conflict with fortran */

Expand Down Expand Up @@ -392,6 +393,7 @@ struct gs_remote {
exec_fun *exec_isend;
exec_fun *exec_wait;
fin_fun *fin;
double exec_timings[3]; // time[0]-pw,time[1]-cr,time[2]-allreduce
};

typedef void setup_fun(struct gs_remote *r, struct gs_topology *top,
Expand Down Expand Up @@ -1089,10 +1091,10 @@ static void allreduce_setup(struct gs_remote *r, struct gs_topology *top,
Automatic Setup --- dynamically picks the fastest method
------------------------------------------------------------------------------*/

static void dry_run_time(double times[3], const struct gs_remote *r,
static double dry_run_time(double times[3], const struct gs_remote *r,
const struct comm *comm, buffer *buf)
{
int i; double t;
int i; double t,tout;
buffer_reserve(buf,gs_dom_size[gs_double]*r->buffer_size);
for(i= 2;i;--i)
r->exec(0,mode_dry_run,1,gs_double,gs_add,0,r->data,comm,buf->ptr);
Expand All @@ -1101,12 +1103,16 @@ static void dry_run_time(double times[3], const struct gs_remote *r,
for(i=10;i;--i)
r->exec(0,mode_dry_run,1,gs_double,gs_add,0,r->data,comm,buf->ptr);
t = (comm_time() - t)/10;
tout = t;
times[0] = t/comm->np, times[1] = t, times[2] = t;
comm_allreduce(comm,gs_double,gs_add, &times[0],1, &t);
comm_allreduce(comm,gs_double,gs_min, &times[1],1, &t);
comm_allreduce(comm,gs_double,gs_max, &times[2],1, &t);

return tout;
}

static int _global_verbose; // used by auto_setup, initialized in gs_setup_aux
static void auto_setup(struct gs_remote *r, struct gs_topology *top,
const struct comm *comm, buffer *buf)
{
Expand All @@ -1117,10 +1123,15 @@ static void auto_setup(struct gs_remote *r, struct gs_topology *top,
struct gs_remote r_alt;
double time[2][3];

double tt[3];
int i; for(i=0; i<3; i++)
tt[i]=DBL_MAX;
int n=0;

#define DRY_RUN(i,gsr,str) do { \
if(comm->id==0) printf(" " str ": "); \
dry_run_time(time[i],gsr,comm,buf); \
if(comm->id==0) \
if(comm->id==0 && _global_verbose) printf(" " str ": "); \
tt[n]=dry_run_time(time[i],gsr,comm,buf); \
if(comm->id==0 && _global_verbose) \
printf("%g %g %g\n",time[i][0],time[i][1],time[i][2]); \
} while(0)

Expand All @@ -1134,19 +1145,25 @@ static void auto_setup(struct gs_remote *r, struct gs_topology *top,
} while(0)

DRY_RUN(0, r, "pairwise times (avg, min, max)");
n++;

cr_setup(&r_alt, top,comm,buf);
DRY_RUN_CHECK( "crystal router ", "crystal router");
n++;

if(top->total_shared<100000) {
allreduce_setup(&r_alt, top,comm,buf);
DRY_RUN_CHECK( "all reduce ", "allreduce");
n++;
}

#undef DRY_RUN_CHECK
#undef DRY_RUN

if(comm->id==0) printf(" used all_to_all method: %s\n",name);
if(comm->id==0 && _global_verbose)
printf(" used all_to_all method: %s\n",name);

memcpy(r->exec_timings,tt,3*sizeof(double));
}
}

Expand Down Expand Up @@ -1410,6 +1427,7 @@ static void gs_setup_aux(struct gs_data *gsh, const slong *id, uint n,
if(verbose && gsh->comm.id==0)
printf("gs_setup: %ld unique labels shared\n",(long)top.total_shared);

_global_verbose=verbose;
remote_setup[method](&gsh->r, &top,&gsh->comm,&cr.data);
gsh->handle_size += gsh->r.mem_size;

Expand Down Expand Up @@ -1444,6 +1462,11 @@ struct gs_data *gs_setup(const slong *id, uint n, const struct comm *comm,
return gsh;
}

void gs_exec_timings(struct gs_data *gsh,double time[3])
{
memcpy(time,gsh->r.exec_timings,3*sizeof(double));
}

void gs_free(struct gs_data *gsh)
{
comm_free(&gsh->comm);
Expand Down
1 change: 1 addition & 0 deletions src/gs.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void gs_wait(int handle);

struct gs_data *gs_setup(const slong *id, uint n, const struct comm *comm,
int unique, gs_method method, int verbose);
void gs_exec_timings(struct gs_data *gsh,double time[3]);
void gs_free(struct gs_data *gsh);
void gs_unique(slong *id, uint n, const struct comm *comm);
struct gs_data* gs_hf2c(const sint gsh);
Expand Down