Commit 5b3cd56b authored by Antoine Jego's avatar Antoine Jego
Browse files

adding by values pass in C

parent 6896c4a6
......@@ -63,6 +63,7 @@ static struct argp_option options[] = {
{"prune-handles",'z', 0, 0, "If handed out to the program, prune the handle registration."},
{"own-context", 'o', 0, 0, "If handed out to the program, schedule tasks in a created context."},
{"nowarmup", 'w', 0, 0, "If handed out to the program, register warmup run."},
{"byvalues", 'V', 0, 0, "If handed out to the program, codelet arguments are handed out through STARPU_VALUE instead of cl_gemm_args struct."},
{"delay", 'D', 0, 0, "If handed out to the program, delay handles registration."},
{ 0 }
};
......@@ -78,6 +79,7 @@ struct arguments
int no_flush, prune, super_prune, prune_handles;
int context;
int warmup;
int values;
int delay;
};
......@@ -147,6 +149,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'D':
arguments->delay = 1;
break;
case 'V':
arguments->values = 1;
break;
default:
return ARGP_ERR_UNKNOWN;
}
......@@ -173,6 +178,7 @@ static int super_prune = 0;
static int prune_handles = 0;
static int context = 0;
static int warmup = 1;
static int values = 1;
static int delay = 0;
#define MB ((M)/(BS)) /* Number of blocks */
......@@ -246,7 +252,6 @@ struct cl_zgemm_args_s {
static void cpu_gemm(void *handles[], void *args)
{
struct cl_zgemm_args_s *clargs = (struct cl_zgemm_args_s *)args;
double *block_A;
double *block_B;
......@@ -283,10 +288,17 @@ static void cpu_gemm(void *handles[], void *args)
}
// if (verbose) printf("gemm_task\n");
// printf("DATA %d | ld A %d B %d C %d | alpha %f beta %f \n", datatype, ld_A, ld_B, ld_C, clargs->alpha, clargs->beta);
double alpha, beta;
if (values) {
starpu_codelet_unpack_args(args, &alpha, &beta);
} else {
struct cl_zgemm_args_s *clargs = (struct cl_zgemm_args_s *)args;
alpha=clargs->alpha; beta=clargs->beta;
}
double start = starpu_timing_now();
cblas_dgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans, // 2
n_row_C, n_col_C, n_col_A, clargs->alpha, block_A, ld_A, block_B, // 9
ld_B, clargs->beta, block_C, ld_C ); // 13
n_row_C, n_col_C, n_col_A, alpha, block_A, ld_A, block_B, // 9
ld_B, beta, block_C, ld_C ); // 13
double stop = starpu_timing_now();
double timing = stop - start;
// printf("gemm_task %f Gflop/s\n", 2.0*n_row_C*n_col_C*n_col_A/(timing*1000));
......@@ -492,6 +504,7 @@ int main(int argc, char *argv[])
arguments.context = 0;
arguments.delay = 0;
arguments.warmup = 1;
arguments.values = 0;
argp_parse(&argp, argc, argv, 0, 0, &arguments);
M = arguments.m;
......@@ -513,6 +526,7 @@ int main(int argc, char *argv[])
context = arguments.context;
delay = arguments.delay;
warmup = arguments.warmup;
values = arguments.values;
/* Initializes StarPU and the StarPU-MPI layer */
starpu_fxt_autostart_profiling(0);
......@@ -580,6 +594,7 @@ int main(int argc, char *argv[])
if (prune_handles) printf("- Handle pruning enabled\n");
if (context) printf("- Submitting own context\n");
if (!warmup) printf("- Warmup disabled\n");
if (values) printf("- Passing by values (instead of cl_args)\n");
if (delay) printf("- Delayed handle registration enabled\n");
}
int barrier_ret, trial;
......@@ -617,6 +632,7 @@ int main(int argc, char *argv[])
int a_local, b_local, c_local;
int b_row,b_col,b_aisle;
double zbeta;
Block *Ail, *Blj, *Cij;
for (b_row = 0; b_row < MB; b_row++)
{
......@@ -649,9 +665,11 @@ int main(int argc, char *argv[])
b_row,b_col, Cij->registered,Cij->hdl,Cij->owner,
b_row,b_aisle,Ail->registered,Ail->hdl,Ail->owner,
b_aisle,b_col,Blj->registered,Blj->hdl,Blj->owner);
clargs = malloc(sizeof( struct cl_zgemm_args_s ));
clargs->alpha = alpha;
clargs->beta = b_aisle==0? beta : 1.0;
if (values) {
clargs = malloc(sizeof( struct cl_zgemm_args_s ));
clargs->alpha = alpha;
clargs->beta = b_aisle==0? beta : 1.0;
}
} else if (verbose){
printf("[%d] insert. C_%d,%d (%d-%p-%d) += A_%d,%d (%d-%p-%d) B_%d,%d (%d-%p-%d)\n", comm_rank,
b_row,b_col, Cij->registered,Cij->hdl,Cij->owner,
......@@ -665,6 +683,14 @@ int main(int argc, char *argv[])
STARPU_R, Ail->hdl,
STARPU_R, Blj->hdl,
STARPU_RW,Cij->hdl, 0);
} else if (values) {
zbeta = b_aisle == 0 ? beta : 1.0;
starpu_mpi_task_insert(MPI_COMM_WORLD, &gemm_cl,
STARPU_VALUE, &alpha, sizeof(double),
STARPU_VALUE, &zbeta, sizeof(double),
STARPU_R, Ail->hdl,
STARPU_R, Blj->hdl,
STARPU_RW,Cij->hdl, 0);
} else {
starpu_mpi_task_insert(MPI_COMM_WORLD, &gemm_cl,
STARPU_CL_ARGS, clargs, sizeof(struct cl_zgemm_args_s),
......
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