From 1f31e2b6731350362f47c2cd5811836c39356484 Mon Sep 17 00:00:00 2001
From: Alycia Lisito <alycia.lisito@inria.fr>
Date: Wed, 14 Feb 2024 16:11:37 +0100
Subject: [PATCH] zgetrf batched: Add an a field in the data structure and
 environment variable to define the batch size

---
 compute/zgetrf.c    | 12 ++++++++----
 control/compute_z.h |  3 ++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/compute/zgetrf.c b/compute/zgetrf.c
index a1887f832..b15e25b11 100644
--- a/compute/zgetrf.c
+++ b/compute/zgetrf.c
@@ -88,6 +88,8 @@ CHAMELEON_zgetrf_WS_Alloc( const CHAM_desc_t *A )
         chameleon_cleanenv( algostr );
     }
 
+    ws->batch_size = chameleon_getenv_get_value_int( "CHAMELEON_GETRF_BATCH_SIZE", 1 );
+
     /* Allocation of U for permutation of the panels */
     if ( ws->alg == ChamGetrfNoPivPerColumn ) {
         chameleon_desc_init( &(ws->U), CHAMELEON_MAT_ALLOC_TILE,
@@ -96,7 +98,7 @@ CHAMELEON_zgetrf_WS_Alloc( const CHAM_desc_t *A )
                              A->mt, A->nt * A->nb, A->p, A->q,
                              NULL, NULL, A->get_rankof_init, A->get_rankof_init_arg );
     }
-    else if ( ( ws->alg == ChamGetrfPPiv ) ||
+    else if ( ( ws->alg == ChamGetrfPPiv )          ||
               ( ws->alg == ChamGetrfPPivPerColumn ) )
     {
         chameleon_desc_init( &(ws->U), CHAMELEON_MAT_ALLOC_TILE,
@@ -108,13 +110,14 @@ CHAMELEON_zgetrf_WS_Alloc( const CHAM_desc_t *A )
 
     /* Set ib to 1 if per column algorithm */
     if ( ( ws->alg == ChamGetrfNoPivPerColumn ) ||
-         ( ws->alg == ChamGetrfPPivPerColumn  ) )
+         ( ws->alg == ChamGetrfPPivPerColumn ) )
     {
         ws->ib = 1;
     }
 
     /* Allocation of Up for the permutation of the diagonal panel per block */
-    if ( ws->alg == ChamGetrfPPiv ) {
+    if ( ws->alg == ChamGetrfPPiv )
+    {
         /* TODO: Should be restricted to diagonal tiles */
         /* Possibly to a single handle with a permutation of the ownership */
         chameleon_desc_init( &(ws->Up), CHAMELEON_MAT_ALLOC_TILE,
@@ -157,7 +160,8 @@ CHAMELEON_zgetrf_WS_Free( void *user_ws )
     {
         chameleon_desc_destroy( &(ws->U) );
     }
-    if ( ws->alg == ChamGetrfPPiv ) {
+    if ( ws->alg == ChamGetrfPPiv )
+    {
         chameleon_desc_destroy( &(ws->Up) );
     }
     free( ws );
diff --git a/control/compute_z.h b/control/compute_z.h
index 2d0923155..645018f83 100644
--- a/control/compute_z.h
+++ b/control/compute_z.h
@@ -43,7 +43,8 @@ struct chameleon_pzgemm_s {
  */
 struct chameleon_pzgetrf_s {
     cham_getrf_t alg;
-    int          ib; /* Internal blocking parameter */
+    int          ib;         /**< Internal blocking parameter */
+    int          batch_size; /**< Batch size for the panel    */
     CHAM_desc_t  U;
     CHAM_desc_t  Up;
 };
-- 
GitLab