Commit 52289146 authored by Antoine Jego's avatar Antoine Jego
Browse files

fixed tile interface

parent 3abb7864
......@@ -396,6 +396,13 @@ ti_handle_get_n( starpu_data_handle_t handle )
return tile->n;
}
int
ti_handle_get_ld( starpu_data_handle_t handle )
{
Block *tile = ti_handle_get( handle );
return tile->ld;
}
size_t
ti_handle_get_allocsize( starpu_data_handle_t handle )
{
......
......@@ -10,7 +10,6 @@ typedef struct starpu_tile_interface_s
{
enum starpu_data_interface_id id; /**< Identifier of the interface */
uintptr_t dev_handle; /**< device handle of the matrix */
double flttype; /**< Type of the elements of the matrix */
size_t allocsize; /**< size actually currently allocated */
size_t tilesize; /**< size of the elements of the matrix */
Block tile; /**< Internal tile structure used to store
......@@ -24,7 +23,9 @@ void starpu_tile_register( starpu_data_handle_t *handleptr,
int ti_handle_get_m ( starpu_data_handle_t handle );
int ti_handle_get_n ( starpu_data_handle_t handle );
size_t ti_handle_get_allocsize( starpu_data_handle_t handle );
static inline Block* ti_interface_get(starpu_tile_interface_t *interface) {
return &(interface->tile);
}
int ti_allocate_datatype( starpu_data_handle_t handle,
MPI_Datatype *datatype );
......
......@@ -29,6 +29,7 @@
#include <starpu.h>
#include <starpu_mpi.h>
#include <cblas.h>
#include <lapacke.h>
#include "dsmat.h"
#include "optional_tile_interface.h"
......@@ -199,44 +200,78 @@ static void unregister_matrices()
}
}
static void cpu_gemm(void *handles[], void *arg)
{
(void)arg;
double *block_A = (double *)STARPU_MATRIX_GET_PTR(handles[0]);
double *block_B = (double *)STARPU_MATRIX_GET_PTR(handles[1]);
double *block_C = (double *)STARPU_MATRIX_GET_PTR(handles[2]);
unsigned n_col_A = STARPU_MATRIX_GET_NX(handles[0]);
unsigned n_col_C = STARPU_MATRIX_GET_NX(handles[2]);
unsigned n_row_C = STARPU_MATRIX_GET_NY(handles[2]);
unsigned ld_A = STARPU_MATRIX_GET_LD(handles[0]);
unsigned ld_B = STARPU_MATRIX_GET_LD(handles[1]);
unsigned ld_C = STARPU_MATRIX_GET_LD(handles[2]);
struct cl_zgemm_args_s {
double alpha;
double beta;
};
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;
double *block_C;
unsigned n_col_A;
unsigned n_col_C;
unsigned n_row_C;
unsigned ld_A;
unsigned ld_B;
unsigned ld_C;
if (datatype) {
Block* A = ti_interface_get(handles[0]);
Block* B = ti_interface_get(handles[1]);
Block* C = ti_interface_get(handles[2]);
block_A = A->c;
block_B = B->c;
block_C = C->c;
n_col_A = A->n;
n_col_C = C->n;
n_row_C = C->m;
ld_A = A->ld;
ld_B = B->ld;
ld_C = C->ld;
} else {
block_A = (double *)STARPU_MATRIX_GET_PTR(handles[0]);
block_B = (double *)STARPU_MATRIX_GET_PTR(handles[1]);
block_C = (double *)STARPU_MATRIX_GET_PTR(handles[2]);
n_col_A = STARPU_MATRIX_GET_NX(handles[0]);
n_col_C = STARPU_MATRIX_GET_NX(handles[2]);
n_row_C = STARPU_MATRIX_GET_NY(handles[2]);
ld_A = STARPU_MATRIX_GET_LD(handles[0]);
ld_B = STARPU_MATRIX_GET_LD(handles[1]);
ld_C = STARPU_MATRIX_GET_LD(handles[2]);
}
// if (verbose) printf("gemm_task\n");
cblas_dgemm( CblasColMajor, CblasNoTrans, CblasNoTrans,
n_row_C, n_col_C, n_col_A, 1.0, block_A, ld_A, block_B,
ld_B, 1.0, block_C, ld_C );
// 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);
cblas_dgemm( CblasColMajor, 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
}
int iseed[4];
static void cpu_fill(void *handles[], void *arg)
{
(void)arg;
double *block_A = (double *)STARPU_MATRIX_GET_PTR(handles[0]);
unsigned n_col_A = STARPU_MATRIX_GET_NX(handles[0]);
unsigned n_row_A = STARPU_MATRIX_GET_NY(handles[0]);
unsigned ld_A = STARPU_MATRIX_GET_LD(handles[0]);
unsigned n_col_A, n_row_A, ld_A;
if (datatype) {
Block* tile = ti_interface_get(handles[0]);
n_col_A = tile->n;
n_row_A = tile->m;
ld_A = tile->ld;
} else {
n_col_A = STARPU_MATRIX_GET_NX(handles[0]);
n_row_A = STARPU_MATRIX_GET_NY(handles[0]);
ld_A = STARPU_MATRIX_GET_LD(handles[0]);
}
int i,j;
//#if (verbose) printf("fill_task\n");
for (i=0;i<n_row_A;i++)
{
for (j=0;j<n_col_A;j++)
{
block_A[i*BS+j] = 1.1;
}
LAPACKE_dlarnv(1,iseed,n_col_A,block_A + i*BS);
}
}
......@@ -268,7 +303,6 @@ static void init_matrix(Matrix* X, starpu_data_handle_t* X_h, int mb, int nb)
{
if (X->blocks[row*nb+col].owner == comm_rank)
{
// printf("%d insert fill X_%d,%d\n",comm_rank,row,col);
starpu_mpi_task_insert(MPI_COMM_WORLD, &fill_cl,
STARPU_W, X_h[row*nb+col], 0);
}
......@@ -380,6 +414,7 @@ int main(int argc, char *argv[])
}
int barrier_ret, trial;
double start, stop;
double alpha = 3.14, beta=0.42;
if (trace) starpu_fxt_start_profiling();
for (trial =0; trial < T; trial++)
{
......@@ -397,12 +432,19 @@ int main(int argc, char *argv[])
{
for (b_aisle=0;b_aisle<KB;b_aisle++)
{
// printf("[%d] inserting C_%d,%d += A_%d,%d B_%d,%d\n",comm_rank, b_row,b_col, b_row,b_aisle, b_aisle,b_col);
// printf("[%d] inserting C_%d,%d += A_%d,%d B_%d,%d\n",comm_rank, b_row,b_col, b_row,b_aisle, b_aisle,b_col);
struct cl_zgemm_args_s *clargs = NULL;
if (C->blocks[b_row*NB+b_col].owner == comm_rank) {
clargs = malloc(sizeof( struct cl_zgemm_args_s ));
clargs->alpha = alpha;
clargs->beta = b_aisle==0? beta : 1.0;
}
starpu_mpi_task_insert(MPI_COMM_WORLD, &gemm_cl,
STARPU_CL_ARGS, clargs, sizeof(struct cl_zgemm_args_s),
STARPU_R, A_h[b_row*KB+b_aisle],
STARPU_R, B_h[b_aisle*NB+b_col],
STARPU_RW, C_h[b_row*NB+b_col], 0);
// printf("[%d] inserted C_%d,%d += A_%d,%d B_%d,%d\n",comm_rank, b_row,b_col, b_row,b_aisle, b_aisle,b_col);
// printf("[%d] inserted C_%d,%d += A_%d,%d B_%d,%d\n",comm_rank, b_row,b_col, b_row,b_aisle, b_aisle,b_col);
}
}
for (b_aisle=0;b_aisle<KB;b_aisle++)
......@@ -424,5 +466,6 @@ int main(int argc, char *argv[])
if (trace) starpu_fxt_stop_profiling();
starpu_mpi_shutdown();
if (mpi_thread > -1) MPI_Finalize();
return 0;
}
Supports Markdown
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