From 04841305e50ee62b05970de4649b9fb9d5ceea3d Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Wed, 15 Nov 2023 11:31:54 +0100
Subject: [PATCH] summa: switch back to generic algorithm when all descriptors
 are not in 2dbc distribution

---
 compute/zgemm.c | 11 +++++++++++
 compute/zhemm.c | 11 +++++++++++
 compute/zsymm.c | 11 +++++++++++
 3 files changed, 33 insertions(+)

diff --git a/compute/zgemm.c b/compute/zgemm.c
index d8892fe79..a567d94e0 100644
--- a/compute/zgemm.c
+++ b/compute/zgemm.c
@@ -174,6 +174,17 @@ void *CHAMELEON_zgemm_WS_Alloc( cham_trans_t       transA __attribute__((unused)
 
     assert( options->alg != ChamGemmAlgAuto );
 
+    /* Switch back to generic if descriptors are not 2dbc */
+    if ( options->alg == ChamGemmAlgSummaC )
+    {
+        if ( (A->get_rankof_init != chameleon_getrankof_2d) ||
+             (B->get_rankof_init != chameleon_getrankof_2d) ||
+             (C->get_rankof_init != chameleon_getrankof_2d) )
+        {
+            options->alg = ChamGemmAlgGeneric;
+        }
+    }
+
     /* Now that we have decided which algorithm, let's allocate the required data structures. */
     if ( options->alg == ChamGemmAlgSummaC )
     {
diff --git a/compute/zhemm.c b/compute/zhemm.c
index 8b01715c4..920d1126a 100644
--- a/compute/zhemm.c
+++ b/compute/zhemm.c
@@ -149,6 +149,17 @@ void *CHAMELEON_zhemm_WS_Alloc( cham_side_t        side __attribute__((unused)),
 
     assert( options->alg != ChamGemmAlgAuto );
 
+    /* Switch back to generic if descriptors are not 2dbc */
+    if ( options->alg == ChamGemmAlgSummaC )
+    {
+        if ( (A->get_rankof_init != chameleon_getrankof_2d) ||
+             (B->get_rankof_init != chameleon_getrankof_2d) ||
+             (C->get_rankof_init != chameleon_getrankof_2d) )
+        {
+            options->alg = ChamGemmAlgGeneric;
+        }
+    }
+
     /* Now that we have decided which algorithm, let's allocate the required data structures. */
     if ( (options->alg == ChamGemmAlgSummaC ) &&
          (C->get_rankof_init == chameleon_getrankof_2d ) )
diff --git a/compute/zsymm.c b/compute/zsymm.c
index f493497b8..4942269cf 100644
--- a/compute/zsymm.c
+++ b/compute/zsymm.c
@@ -149,6 +149,17 @@ void *CHAMELEON_zsymm_WS_Alloc( cham_side_t        side __attribute__((unused)),
 
     assert( options->alg != ChamGemmAlgAuto );
 
+    /* Switch back to generic if descriptors are not 2dbc */
+    if ( options->alg == ChamGemmAlgSummaC )
+    {
+        if ( (A->get_rankof_init != chameleon_getrankof_2d) ||
+             (B->get_rankof_init != chameleon_getrankof_2d) ||
+             (C->get_rankof_init != chameleon_getrankof_2d) )
+        {
+            options->alg = ChamGemmAlgGeneric;
+        }
+    }
+
     /* Now that we have decided which algorithm, let's allocate the required data structures. */
     if ( (options->alg == ChamGemmAlgSummaC ) &&
          (C->get_rankof_init == chameleon_getrankof_2d ) )
-- 
GitLab