Commit 4e9489c9 authored by Mathieu Faverge's avatar Mathieu Faverge

Merge branch 'migration' into 'master'

Migration QR/LQ

See merge request solverstack/chameleon!81
parents d2f214d3 2685add3
......@@ -102,6 +102,9 @@ set( RP_CHAMELEON_DICTIONNARY ${MORSE_CMAKE_MODULE_PATH}/precision_generator/sub
set( RP_CHAMELEON_PRECISIONS "s;d;c;z" )
include(RulesPrecisions)
option(CHAMELEON_USE_MIGRATE
"This options enables the data migration in QR algorithms" ON)
# Options to select the runtime
# -----------------------------
......
Subproject commit a5142c9b74e6bfa007142aff48c3c70f99805995
Subproject commit 50671b7b85920f15297a489443b1548ceb6ebc53
......@@ -35,7 +35,7 @@
#if defined(CHAMELEON_COPY_DIAG)
#define D(k) D, k, 0
#else
#define D(k) A, k, k
#define D(k) D, k, k
#endif
/*******************************************************************************
......@@ -67,6 +67,10 @@ void morse_pzgelqf(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
minMNT = A->mt;
}
if ( D == NULL ) {
D = A;
}
/*
* zgelqt = A->nb * (ib+1)
* zunmlq = A->nb * ib
......@@ -130,26 +134,41 @@ void morse_pzgelqf(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
}
for (n = k+1; n < A->nt; n++) {
tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
MORSE_TASK_ztslqt(
RUNTIME_data_migrate( sequence, A(k, k),
A->get_rankof( A, k, n ) );
/* TS kernel */
MORSE_TASK_ztplqt(
&options,
tempkm, tempnn, ib, T->nb,
tempkm, tempnn, 0, ib, T->nb,
A(k, k), ldak,
A(k, n), ldak,
T(k, n), T->mb);
for (m = k+1; m < A->mt; m++) {
tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
ldam = BLKLDD(A, m);
MORSE_TASK_ztsmlq(
RUNTIME_data_migrate( sequence, A(m, k),
A->get_rankof( A, m, n ) );
MORSE_TASK_ztpmlqt(
&options,
MorseRight, MorseConjTrans,
tempmm, A->nb, tempmm, tempnn, A->mb, ib, T->nb,
A(m, k), ldam,
A(m, n), ldam,
tempmm, tempnn, A->mb, 0, ib, T->nb,
A(k, n), ldak,
T(k, n), T->mb);
T(k, n), T->mb,
A(m, k), ldam,
A(m, n), ldam);
}
}
/* Restore the original location of the tiles */
for (m = k; m < A->mt; m++) {
RUNTIME_data_migrate( sequence, A(m, k),
A->get_rankof( A, m, k ) );
}
RUNTIME_iteration_pop(morse);
}
......
......@@ -26,14 +26,10 @@
#include <stdlib.h>
#include "libhqr.h"
#define A(m,n) A, (m), (n)
#define TS(m,n) TS, (m), (n)
#define TT(m,n) TT, (m), (n)
#if defined(CHAMELEON_COPY_DIAG)
#define D(m,n) D, (m), (n)
#else
#define D(m,n) A, (m), (n)
#endif
#define A(m,n) A, (m), (n)
#define T(m,n) T, (m), (n)
#define D(m,n) D, (m), (n)
/*
* Parallel tile LQ factorization (reduction Householder) - dynamic scheduling
......@@ -44,11 +40,12 @@ void morse_pzgelqf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
{
MORSE_context_t *morse;
MORSE_option_t options;
MORSE_desc_t *T;
size_t ws_worker = 0;
size_t ws_host = 0;
int k, m, n, i, p;
int K;
int K, L;
int ldak, ldam;
int tempkmin, tempkm, tempnn, tempmm, temppn;
int ib;
......@@ -61,6 +58,10 @@ void morse_pzgelqf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
ib = MORSE_IB;
if ( D == NULL ) {
D = A;
}
/*
* zgelqt = A->nb * (ib+1)
* zunmlq = A->nb * ib
......@@ -98,6 +99,8 @@ void morse_pzgelqf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
ldak = BLKLDD(A, k);
T = TS;
/* The number of geqrt to apply */
for (i = 0; i < qrtree->getnbgeqrf(qrtree, k); i++) {
p = qrtree->getm(qrtree, k, i);
......@@ -106,9 +109,9 @@ void morse_pzgelqf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
MORSE_TASK_zgelqt(
&options,
tempkm, temppn, ib, TS->nb,
tempkm, temppn, ib, T->nb,
A( k, p), ldak,
TS(k, p), TS->mb);
T(k, p), T->mb);
if ( k < (A->mt-1) ) {
#if defined(CHAMELEON_COPY_DIAG)
MORSE_TASK_zlacpy(
......@@ -131,10 +134,10 @@ void morse_pzgelqf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
MORSE_TASK_zunmlq(
&options,
MorseRight, MorseConjTrans,
tempmm, temppn, tempkmin, ib, TS->nb,
D( k, p), ldak,
TS(k, p), TS->mb,
A( m, p), ldam);
tempmm, temppn, tempkmin, ib, T->nb,
D(k, p), ldak,
T(k, p), T->mb,
A(m, p), ldam);
}
}
......@@ -146,58 +149,61 @@ void morse_pzgelqf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
p = qrtree->currpiv(qrtree, k, n);
tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
temppn = p == A->nt-1 ? A->n-p*A->nb : A->nb;
/* Tiles killed is a TS */
if(qrtree->gettype(qrtree, k, n) == 0){
MORSE_TASK_ztslqt(
&options,
tempkm, tempnn, ib, TS->nb,
A( k, p), ldak,
A( k, n), ldak,
TS(k, n), TS->mb);
for (m = k+1; m < A->mt; m++) {
tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
ldam = BLKLDD(A, m);
MORSE_TASK_ztsmlq(
&options,
MorseRight, MorseConjTrans,
tempmm, A->nb, tempmm, tempnn, tempkm, ib, TS->nb,
A( m, p), ldam,
A( m, n), ldam,
A( k, n), ldak,
TS(k, n), TS->mb);
}
if (qrtree->gettype(qrtree, k, n) == 0) {
/* TS kernel */
T = TS;
L = 0;
}
/* Tiles killed is a TT */
else {
MORSE_TASK_zttlqt(
/* TT kernel */
T = TT;
L = tempnn;
}
RUNTIME_data_migrate( sequence, A(k, p),
A->get_rankof( A, k, n ) );
RUNTIME_data_migrate( sequence, A(k, n),
A->get_rankof( A, k, n ) );
MORSE_TASK_ztplqt(
&options,
tempkm, tempnn, chameleon_min(L, tempkm), ib, T->nb,
A(k, p), ldak,
A(k, n), ldak,
T(k, n), T->mb);
for (m = k+1; m < A->mt; m++) {
tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
ldam = BLKLDD(A, m);
RUNTIME_data_migrate( sequence, A(m, p),
A->get_rankof( A, m, n ) );
RUNTIME_data_migrate( sequence, A(m, n),
A->get_rankof( A, m, n ) );
MORSE_TASK_ztpmlqt(
&options,
tempkm, tempnn, ib, TT->nb,
A( k, p), ldak,
A( k, n), ldak,
TT(k, n), TT->mb);
for (m = k+1; m < A->mt; m++) {
tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
ldam = BLKLDD(A, m);
MORSE_TASK_zttmlq(
&options,
MorseRight, MorseConjTrans,
tempmm, A->nb, tempmm, tempnn, tempkm, ib, TT->nb,
A( m, p), ldam,
A( m, n), ldam,
A( k, n), ldak,
TT(k, n), TT->mb);
}
MorseRight, MorseConjTrans,
tempmm, tempnn, tempkm, L, ib, T->nb,
A(k, n), ldak,
T(k, n), T->mb,
A(m, p), ldam,
A(m, n), ldam);
}
}
/* Restore the original location of the tiles */
for (m = k; m < A->mt; m++) {
RUNTIME_data_migrate( sequence, A(m, k),
A->get_rankof( A, m, k ) );
}
RUNTIME_iteration_pop(morse);
}
free(tiles);
RUNTIME_options_ws_free(&options);
RUNTIME_options_finalize(&options, morse);
(void)D;
}
......@@ -131,11 +131,17 @@ void morse_pzgelqfrh(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D, int BS,
T(k, N), T->mb,
A(m, N), ldam);
}
for (n = N+1; n < chameleon_min(N+BS, A->nt); n++) {
tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
MORSE_TASK_ztslqt(
RUNTIME_data_migrate( sequence, A(k, N),
A->get_rankof( A, k, n ) );
/* TS kernel */
MORSE_TASK_ztplqt(
&options,
tempkm, tempnn, ib, T->nb,
tempkm, tempnn, 0, ib, T->nb,
A(k, N), ldak,
A(k, n), ldak,
T(k, n), T->mb);
......@@ -143,23 +149,34 @@ void morse_pzgelqfrh(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D, int BS,
for (m = k+1; m < A->mt; m++) {
tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
ldam = BLKLDD(A, m);
MORSE_TASK_ztsmlq(
RUNTIME_data_migrate( sequence, A(m, N),
A->get_rankof( A, m, n ) );
MORSE_TASK_ztpmlqt(
&options,
MorseRight, MorseConjTrans,
tempmm, A->nb, tempmm, tempnn, tempkm, ib, T->nb,
A(m, N), ldam,
A(m, n), ldam,
tempmm, tempnn, tempkm, 0, ib, T->nb,
A(k, n), ldak,
T(k, n), T->mb);
T(k, n), T->mb,
A(m, N), ldam,
A(m, n), ldam);
}
}
}
for (RD = BS; RD < A->nt-k; RD *= 2) {
for (N = k; N+RD < A->nt; N += 2*RD) {
tempNRDn = N+RD == A->nt-1 ? A->n-(N+RD)*A->nb : A->nb;
MORSE_TASK_zttlqt(
RUNTIME_data_migrate( sequence, A(k, N),
A->get_rankof( A, k, N+RD ) );
RUNTIME_data_migrate( sequence, A(k, N+RD),
A->get_rankof( A, k, N+RD ) );
/* TT kernel */
MORSE_TASK_ztplqt(
&options,
tempkm, tempNRDn, ib, T->nb,
tempkm, tempNRDn, chameleon_min(tempNRDn, tempkm), ib, T->nb,
A (k, N ), ldak,
A (k, N+RD), ldak,
T2(k, N+RD), T->mb);
......@@ -167,17 +184,30 @@ void morse_pzgelqfrh(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D, int BS,
for (m = k+1; m < A->mt; m++) {
tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
ldam = BLKLDD(A, m );
MORSE_TASK_zttmlq(
RUNTIME_data_migrate( sequence, A(m, N),
A->get_rankof( A, m, N+RD ) );
RUNTIME_data_migrate( sequence, A(m, N+RD),
A->get_rankof( A, m, N+RD ) );
MORSE_TASK_ztpmlqt(
&options,
MorseRight, MorseConjTrans,
tempmm, A->nb, tempmm, tempNRDn, tempkm, ib, T->nb,
A (m, N ), ldam,
A (m, N+RD), ldam,
tempmm, tempNRDn, tempkm, tempNRDn, ib, T->nb,
A (k, N+RD), ldak,
T2(k, N+RD), T->mb);
T2(k, N+RD), T->mb,
A (m, N ), ldam,
A (m, N+RD), ldam);
}
}
}
/* Restore the original location of the tiles */
for (m = k; m < A->mt; m++) {
RUNTIME_data_migrate( sequence, A(m, k),
A->get_rankof( A, m, k ) );
}
RUNTIME_iteration_pop(morse);
}
......
......@@ -33,9 +33,9 @@
#define A(m,n) A, m, n
#define T(m,n) T, m, n
#if defined(CHAMELEON_COPY_DIAG)
#define D(k) D, k, 0
#define D(k) D, k, 0
#else
#define D(k) A, k, k
#define D(k) D, k, k
#endif
/*******************************************************************************
......@@ -62,6 +62,10 @@ void morse_pzgeqrf(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
ib = MORSE_IB;
if ( D == NULL ) {
D = A;
}
/*
* zgeqrt = A->nb * (ib+1)
* zunmqr = A->nb * ib
......@@ -122,28 +126,46 @@ void morse_pzgeqrf(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
T(k, k), T->mb,
A(k, n), ldak);
}
for (m = k+1; m < A->mt; m++) {
tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
ldam = BLKLDD(A, m);
MORSE_TASK_ztsqrt(
RUNTIME_data_migrate( sequence, A(k, k),
A->get_rankof( A, m, k ) );
/* TS kernel */
MORSE_TASK_ztpqrt(
&options,
tempmm, tempkn, ib, T->nb,
tempmm, tempkn, 0, ib, T->nb,
A(k, k), ldak,
A(m, k), ldam,
T(m, k), T->mb);
for (n = k+1; n < A->nt; n++) {
tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
MORSE_TASK_ztsmqr(
RUNTIME_data_migrate( sequence, A(k, n),
A->get_rankof( A, m, n ) );
/* TS kernel */
MORSE_TASK_ztpmqrt(
&options,
MorseLeft, MorseConjTrans,
A->mb, tempnn, tempmm, tempnn, A->nb, ib, T->nb,
A(k, n), ldak,
A(m, n), ldam,
tempmm, tempnn, A->nb, 0, ib, T->nb,
A(m, k), ldam,
T(m, k), T->mb);
T(m, k), T->mb,
A(k, n), ldak,
A(m, n), ldam);
}
}
/* Restore the original location of the tiles */
for (n = k; n < A->nt; n++) {
RUNTIME_data_migrate( sequence, A(k, n),
A->get_rankof( A, k, n ) );
}
RUNTIME_iteration_pop(morse);
}
......
......@@ -26,14 +26,9 @@
#include <stdlib.h>
#include "libhqr.h"
#define A(m,n) A, (m), (n)
#define TS(m,n) TS, (m), (n)
#define TT(m,n) TT, (m), (n)
#if defined(CHAMELEON_COPY_DIAG)
#define D(m,n) D, (m), (n)
#else
#define D(m,n) A, (m), (n)
#endif
#define A(m,n) A, (m), (n)
#define T(m,n) T, (m), (n)
#define D(m,n) D, (m), (n)
/**
* Parallel tile QR factorization (reduction Householder) - dynamic scheduling
......@@ -44,11 +39,12 @@ void morse_pzgeqrf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
{
MORSE_context_t *morse;
MORSE_option_t options;
MORSE_desc_t *T;
size_t ws_worker = 0;
size_t ws_host = 0;
int k, m, n, i, p;
int K;
int K, L;
int ldap, ldam;
int tempkmin, tempkn, tempnn, tempmm;
int ib;
......@@ -61,6 +57,10 @@ void morse_pzgeqrf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
ib = MORSE_IB;
if ( D == NULL ) {
D = A;
}
/*
* zgeqrt = A->nb * (ib+1)
* zunmqr = A->nb * ib
......@@ -81,8 +81,7 @@ void morse_pzgeqrf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
ws_worker = chameleon_max( ws_worker, ib * A->nb * 2 );
#endif
/* Initialisation of tiles */
/* Initialisation of temporary tiles array */
tiles = (int*)calloc(qrtree->mt, sizeof(int));
ws_worker *= sizeof(MORSE_Complex64_t);
......@@ -104,11 +103,13 @@ void morse_pzgeqrf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
tempkmin = chameleon_min(tempmm, tempkn);
ldam = BLKLDD(A, m);
T = TS;
MORSE_TASK_zgeqrt(
&options,
tempmm, tempkn, ib, TS->nb,
A( m, k), ldam,
TS(m, k), TS->mb);
tempmm, tempkn, ib, T->nb,
A(m, k), ldam,
T(m, k), T->mb);
if ( k < (A->nt-1) ) {
#if defined(CHAMELEON_COPY_DIAG)
MORSE_TASK_zlacpy(
......@@ -130,10 +131,10 @@ void morse_pzgeqrf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
MORSE_TASK_zunmqr(
&options,
MorseLeft, MorseConjTrans,
tempmm, tempnn, tempkmin, ib, TS->nb,
D( m, k), ldam,
TS(m, k), TS->mb,
A( m, n), ldam);
tempmm, tempnn, tempkmin, ib, T->nb,
D(m, k), ldam,
T(m, k), T->mb,
A(m, n), ldam);
}
}
......@@ -148,55 +149,58 @@ void morse_pzgeqrf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
ldap = BLKLDD(A, p);
ldam = BLKLDD(A, m);
/* Tiles killed is a TS */
if(qrtree->gettype(qrtree, k, m) == 0){
MORSE_TASK_ztsqrt(
&options,
tempmm, tempkn, ib, TS->nb,
A( p, k), ldap,
A( m, k), ldam,
TS(m, k), TS->mb);
for (n = k+1; n < A->nt; n++) {
tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
MORSE_TASK_ztsmqr(
&options,
MorseLeft, MorseConjTrans,
A->nb, tempnn, tempmm, tempnn, A->nb, ib, TS->nb,
A( p, n), ldap,
A( m, n), ldam,
A( m, k), ldam,
TS(m, k), TS->mb);
}
if (qrtree->gettype(qrtree, k, m) == 0) {
/* TS kernel */
T = TS;
L = 0;
}
/* Tiles killed is a TT */
else {
MORSE_TASK_zttqrt(
/* TT kernel */
T = TT;
L = tempmm;
}
RUNTIME_data_migrate( sequence, A(p, k),
A->get_rankof( A, m, k ) );
RUNTIME_data_migrate( sequence, A(m, k),
A->get_rankof( A, m, k ) );
MORSE_TASK_ztpqrt(
&options,
tempmm, tempkn, chameleon_min(L, tempkn), ib, T->nb,
A(p, k), ldap,
A(m, k), ldam,
T(m, k), T->mb);
for (n = k+1; n < A->nt; n++) {
tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
RUNTIME_data_migrate( sequence, A(p, n),
A->get_rankof( A, m, n ) );
RUNTIME_data_migrate( sequence, A(m, n),
A->get_rankof( A, m, n ) );
MORSE_TASK_ztpmqrt(
&options,
tempmm, tempkn, ib, TT->nb,
A( p, k), ldap,
A( m, k), ldam,
TT(m, k), TT->mb);
for (n = k+1; n < A->nt; n++) {
tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
MORSE_TASK_zttmqr(
&options,
MorseLeft, MorseConjTrans,
A->mb, tempnn, tempmm, tempnn, A->nb, ib, TT->nb,
A( p, n), ldap,
A( m, n), ldam,
A( m, k), ldam,
TT(m, k), TT->mb);
}
MorseLeft, MorseConjTrans,
tempmm, tempnn, A->nb, L, ib, T->nb,
A(m, k), ldam,
T(m, k), T->mb,
A(p, n), ldap,
A(m, n), ldam);
}
}
/* Restore the original location of the tiles */