From c88c6bc198e420bbd14ab60ada276ac099e366ed Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Tue, 9 Jan 2018 11:06:24 +0100
Subject: [PATCH] Allocate and Bcast values array only if non pattern matrix
 has been read

---
 spm_read_driver.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/spm_read_driver.c b/spm_read_driver.c
index 02f3d0fd..e92f7c50 100644
--- a/spm_read_driver.c
+++ b/spm_read_driver.c
@@ -163,14 +163,20 @@ spmReadDriver( pastix_driver_t  driver,
         {
             spm->colptr = (pastix_int_t *) malloc((spm->gN+1) * sizeof(pastix_int_t));
             spm->rowptr = (pastix_int_t *) malloc(nnz * sizeof(pastix_int_t));
-            spm->values = (void *)         malloc(nnz * pastix_size_of( spm->flttype ));
             spm->loc2glob = NULL;
             spm->loc2glob = NULL;
         }
 
         MPI_Bcast( spm->colptr, spm->gN+1, PASTIX_MPI_INT, 0, comm );
         MPI_Bcast( spm->rowptr, nnz,       PASTIX_MPI_INT, 0, comm );
-        MPI_Bcast( spm->values, nnz * pastix_size_of( spm->flttype ), MPI_CHAR, 0, comm );
+
+        if ( spm->flttype != PastixPattern ) {
+            size_t eltsize = pastix_size_of( spm->flttype );
+            if ( mpirank != 0 ) {
+                spm->values = (void *) malloc(nnz * eltsize);
+            }
+            MPI_Bcast( spm->values, nnz * eltsize, MPI_CHAR, 0, comm );
+        }
     }
 
     spmUpdateComputedFields( spm );
-- 
GitLab