From 89258dd17c8c15b4b308f355fd4d83f5a05023a4 Mon Sep 17 00:00:00 2001
From: Abel Calluaud <abel.calluaud@protonmail.com>
Date: Wed, 27 Sep 2023 09:59:00 +0200
Subject: [PATCH] hmat: Rename HMAT to HMAT_OSS to avoid confusion

---
 CMakeLists.txt                                |  6 +++---
 cmake_modules/CHAMELEONConfig.cmake.in        |  2 +-
 cmake_modules/PrintOpts.cmake                 |  2 +-
 coreblas/CMakeLists.txt                       |  2 +-
 coreblas/compute/CMakeLists.txt               |  4 ++--
 coreblas/compute/core_ztile.c                 | 21 ++++++++-----------
 coreblas/compute/core_ztile_empty.c           |  2 +-
 coreblas/include/CMakeLists.txt               |  4 ++--
 coreblas/include/coreblas/hmat.h              |  2 +-
 doc/user/chapters/installing.org              |  2 +-
 include/chameleon/config.h.in                 |  2 +-
 .../starpu/interface/cham_tile_interface.c    |  8 +++----
 testing/CMakeLists.txt                        |  2 +-
 13 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d12130c8..f90423ad4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,10 +230,10 @@ else()
 endif()
 
 # Enable Hmat-OSS kernels
-option(CHAMELEON_USE_HMAT "Enable hmat kernels" OFF)
+option(CHAMELEON_USE_HMATOSS "Enable hmat kernels" OFF)
 cmake_dependent_option(CHAMELEON_HMAT_EXTERNAL
                     "Use external hmat-oss library" OFF
-                    "CHAMELEON_USE_HMAT" OFF)
+                    "CHAMELEON_USE_HMATOSS" OFF)
 
 option(CHAMELEON_RUNTIME_SYNC "Enable synchronous task submission when available to debug the code without parallelism" OFF)
 if (CHAMELEON_RUNTIME_SYNC)
@@ -314,7 +314,7 @@ add_subdirectory(hqr)
 ###############################################################################
 # Build dependency HMAT-OSS library #
 #####################################
-if ( CHAMELEON_USE_HMAT )
+if ( CHAMELEON_USE_HMATOSS )
   if ( CHAMELEON_HMAT_EXTERNAL )
     find_package(HMAT REQUIRED)
     if(HMAT_FOUND)
diff --git a/cmake_modules/CHAMELEONConfig.cmake.in b/cmake_modules/CHAMELEONConfig.cmake.in
index 744cdd723..b1f50a438 100644
--- a/cmake_modules/CHAMELEONConfig.cmake.in
+++ b/cmake_modules/CHAMELEONConfig.cmake.in
@@ -39,7 +39,7 @@ if (@CHAMELEON_USE_CUDA@ AND NOT @CHAMELEON_SIMULATION@)
 endif()
 
 # add the targets file
-if (@CHAMELEON_USE_HMAT@)
+if (@CHAMELEON_USE_HMATOSS@)
   if ( @CHAMELEON_HMAT_EXTERNAL@ )
     # Should be a find_dependency() but we fix it to make sure we use
     # the correct path in higher level projects.
diff --git a/cmake_modules/PrintOpts.cmake b/cmake_modules/PrintOpts.cmake
index e1e604ab7..afe5bd807 100644
--- a/cmake_modules/PrintOpts.cmake
+++ b/cmake_modules/PrintOpts.cmake
@@ -88,7 +88,7 @@ set(dep_message "${dep_message}"
 "       Kernels specific\n"
 "       BLAS ................: ${BLAS_VENDOR_FOUND}\n"
 "       LAPACK...............: ${LAPACK_VENDOR_FOUND}\n"
-"       HMAT-OSS.............: ${CHAMELEON_USE_HMAT}\n"
+"       HMAT-OSS.............: ${CHAMELEON_USE_HMATOSS}\n"
 "\n"
 "       Simulation mode .....: ${CHAMELEON_SIMULATION}\n"
 "\n"
diff --git a/coreblas/CMakeLists.txt b/coreblas/CMakeLists.txt
index 331182ff5..909dfbf5b 100644
--- a/coreblas/CMakeLists.txt
+++ b/coreblas/CMakeLists.txt
@@ -26,7 +26,7 @@
 #
 ###
 
-if (CHAMELEON_USE_HMAT AND NOT CHAMELEON_HMAT_EXTERNAL)
+if (CHAMELEON_USE_HMATOSS AND NOT CHAMELEON_HMAT_EXTERNAL)
   add_subdirectory(hmat-oss)
 endif()
 add_subdirectory(include)
diff --git a/coreblas/compute/CMakeLists.txt b/coreblas/compute/CMakeLists.txt
index adca67101..4f68a6df2 100644
--- a/coreblas/compute/CMakeLists.txt
+++ b/coreblas/compute/CMakeLists.txt
@@ -112,7 +112,7 @@ set(ZSRC
     core_zunmqr.c
     core_zprint.c
     )
-if( CHAMELEON_USE_HMAT )
+if( CHAMELEON_USE_HMATOSS )
   list( APPEND ZSRC
     hmat_z.c )
 endif()
@@ -157,7 +157,7 @@ target_include_directories(coreblas PUBLIC
   $<INSTALL_INTERFACE:include>)
 set_property(TARGET coreblas PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
 
-if( CHAMELEON_USE_HMAT )
+if( CHAMELEON_USE_HMATOSS )
   target_link_libraries(coreblas PUBLIC HMAT::hmat )
 endif()
 
diff --git a/coreblas/compute/core_ztile.c b/coreblas/compute/core_ztile.c
index f3fa2e473..3fd42a0ed 100644
--- a/coreblas/compute/core_ztile.c
+++ b/coreblas/compute/core_ztile.c
@@ -20,7 +20,7 @@
 #include "coreblas.h"
 #include "coreblas/coreblas_ztile.h"
 
-#if defined( CHAMELEON_USE_HMAT )
+#if defined( CHAMELEON_USE_HMATOSS )
 #include "coreblas/hmat.h"
 #endif
 
@@ -137,10 +137,8 @@ TCORE_zgemm( cham_trans_t          transA,
                     beta,
                     CHAM_tile_get_ptr( C ), C->ld );
     }
-#if defined( CHAMELEON_USE_HMAT )
-    else if ( ( A->format & CHAMELEON_TILE_HMAT ) &&
-              ( B->format & CHAMELEON_TILE_HMAT ) &&
-              ( C->format & CHAMELEON_TILE_HMAT ) )
+#if defined( CHAMELEON_USE_HMATOSS )
+    else if ( ( A->format & B->format & C->format & CHAMELEON_TILE_HMAT ) )
     {
         hmat_zgemm( chameleon_lapack_const( transA ),
                     chameleon_lapack_const( transB ),
@@ -148,8 +146,7 @@ TCORE_zgemm( cham_trans_t          transA,
                     &beta, C->mat );
     }
     else if ( ( A->format & CHAMELEON_TILE_HMAT     ) &&
-              ( B->format & CHAMELEON_TILE_FULLRANK ) &&
-              ( C->format & CHAMELEON_TILE_FULLRANK ) )
+              ( B->format & C->format & CHAMELEON_TILE_FULLRANK ) )
     {
         assert( transB == ChamNoTrans );
         hmat_zgemv( chameleon_lapack_const( transA ),
@@ -206,7 +203,7 @@ TCORE_zgetrf( int M, int N, CHAM_tile_t *A, int *IPIV, int *INFO )
     if ( A->format & (CHAMELEON_TILE_FULLRANK | CHAMELEON_TILE_DESC) ) {
         rc = CORE_zgetrf( M, N, CHAM_tile_get_ptr( A ), A->ld, IPIV, INFO );
     }
-#if defined( CHAMELEON_USE_HMAT )
+#if defined( CHAMELEON_USE_HMATOSS )
     else if ( A->format & CHAMELEON_TILE_HMAT ) {
         rc = hmat_zgetrf( A->mat );
         assert( rc == 0 );
@@ -226,7 +223,7 @@ TCORE_zgetrf_incpiv( int M, int N, int IB, CHAM_tile_t *A, int *IPIV, int *INFO
     if ( A->format & (CHAMELEON_TILE_FULLRANK | CHAMELEON_TILE_DESC) ) {
         return CORE_zgetrf_incpiv( M, N, IB, CHAM_tile_get_ptr( A ), A->ld, IPIV, INFO );
     }
-#if defined( CHAMELEON_USE_HMAT )
+#if defined( CHAMELEON_USE_HMATOSS )
     else if ( A->format & CHAMELEON_TILE_HMAT ) {
         return hmat_zgetrf( A->mat );
     }
@@ -248,7 +245,7 @@ TCORE_zgetrf_nopiv( int M, int N, int IB, CHAM_tile_t *A, int *INFO )
     if ( A->format & (CHAMELEON_TILE_FULLRANK | CHAMELEON_TILE_DESC) ) {
         rc = CORE_zgetrf_nopiv( M, N, IB, CHAM_tile_get_ptr( A ), A->ld, INFO );
     }
-#if defined( CHAMELEON_USE_HMAT )
+#if defined( CHAMELEON_USE_HMATOSS )
     else if ( A->format & CHAMELEON_TILE_HMAT ) {
         rc     = hmat_zgetrf( A->mat );
         assert( rc == 0 );
@@ -556,7 +553,7 @@ TCORE_zpotrf( cham_uplo_t uplo, int n, CHAM_tile_t *A, int *INFO )
     if ( A->format & (CHAMELEON_TILE_FULLRANK | CHAMELEON_TILE_DESC) ) {
         CORE_zpotrf( uplo, n, CHAM_tile_get_ptr( A ), A->ld, INFO );
     }
-#if defined( CHAMELEON_USE_HMAT )
+#if defined( CHAMELEON_USE_HMATOSS )
     else if ( A->format & CHAMELEON_TILE_HMAT ) {
         assert( uplo == ChamLower );
         *INFO = hmat_zpotrf( A->mat );
@@ -854,7 +851,7 @@ TCORE_ztrsm( cham_side_t           side,
     {
         CORE_ztrsm( side, uplo, transA, diag, M, N, alpha, CHAM_tile_get_ptr( A ), A->ld, CHAM_tile_get_ptr( B ), B->ld );
     }
-#if defined( CHAMELEON_USE_HMAT )
+#if defined( CHAMELEON_USE_HMATOSS )
     else if ( A->format & CHAMELEON_TILE_HMAT ) {
         assert( !(B->format & CHAMELEON_TILE_DESC) );
         hmat_ztrsm( chameleon_lapack_const( side ),
diff --git a/coreblas/compute/core_ztile_empty.c b/coreblas/compute/core_ztile_empty.c
index 78deca420..adeb5db17 100644
--- a/coreblas/compute/core_ztile_empty.c
+++ b/coreblas/compute/core_ztile_empty.c
@@ -19,7 +19,7 @@
 #include "coreblas.h"
 #include "coreblas/coreblas_ztile.h"
 
-#if defined( CHAMELEON_USE_HMAT )
+#if defined( CHAMELEON_USE_HMATOSS )
 #include "coreblas/hmat.h"
 #endif
 
diff --git a/coreblas/include/CMakeLists.txt b/coreblas/include/CMakeLists.txt
index c6b9c53c4..2a5651ac0 100644
--- a/coreblas/include/CMakeLists.txt
+++ b/coreblas/include/CMakeLists.txt
@@ -35,7 +35,7 @@ set(ZHDR
   coreblas/coreblas_ztile.h
   coreblas/coreblas_zctile.h
 )
-if( CHAMELEON_USE_HMAT )
+if( CHAMELEON_USE_HMATOSS )
   list( APPEND ZHDR
     coreblas/hmat_z.h )
 endif()
@@ -56,7 +56,7 @@ set(COREBLAS_HDRS
     coreblas/lapacke_mangling.h
     coreblas/random.h
     )
-if( CHAMELEON_USE_HMAT )
+if( CHAMELEON_USE_HMATOSS )
   list( APPEND COREBLAS_HDRS
     coreblas/hmat.h )
 endif()
diff --git a/coreblas/include/coreblas/hmat.h b/coreblas/include/coreblas/hmat.h
index 8cdda1e92..267332bc1 100644
--- a/coreblas/include/coreblas/hmat.h
+++ b/coreblas/include/coreblas/hmat.h
@@ -22,7 +22,7 @@
 
 #include "coreblas.h"
 
-#if !defined( CHAMELEON_USE_HMAT )
+#if !defined( CHAMELEON_USE_HMATOSS )
 #error "This file should not be included by itself"
 #endif
 
diff --git a/doc/user/chapters/installing.org b/doc/user/chapters/installing.org
index de4e61666..8724ccffc 100644
--- a/doc/user/chapters/installing.org
+++ b/doc/user/chapters/installing.org
@@ -399,7 +399,7 @@ Finally some packages or also available for [[sec:ug:debian][Debian/Ubuntu]] and
         enables the data migration in QR algorithms.
       * *CHAMELEON_USE_MPI_DATATYPES* (default OFF):
         enables MPI datatypes whenever supported by the runtime.
-      * *CHAMELEON_USE_HMAT=ON|OFF* (default OFF):
+      * *CHAMELEON_USE_HMATOSS=ON|OFF* (default OFF):
         enables Hmat-OSS kernels.
       * *CHAMELEON_RUNTIME_SYNC* (default OFF):
         enables synchronous task submission when available to debug the code without parallelism.
diff --git a/include/chameleon/config.h.in b/include/chameleon/config.h.in
index 2912a83a0..c9ddebbfb 100644
--- a/include/chameleon/config.h.in
+++ b/include/chameleon/config.h.in
@@ -66,7 +66,7 @@
 #cmakedefine CHAMELEON_PREC_ZC
 
 /* Hmat-oss */
-#cmakedefine CHAMELEON_USE_HMAT
+#cmakedefine CHAMELEON_USE_HMATOSS
 
 /* Simulation */
 #cmakedefine CHAMELEON_SIMULATION
diff --git a/runtime/starpu/interface/cham_tile_interface.c b/runtime/starpu/interface/cham_tile_interface.c
index 50250747e..c8be6122b 100644
--- a/runtime/starpu/interface/cham_tile_interface.c
+++ b/runtime/starpu/interface/cham_tile_interface.c
@@ -17,7 +17,7 @@
  *
  */
 #include "chameleon_starpu.h"
-#if defined(CHAMELEON_USE_HMAT)
+#if defined(CHAMELEON_USE_HMATOSS)
 #include "coreblas/hmat.h"
 
 static inline void
@@ -177,7 +177,7 @@ cti_free_data_on_node( void *data_interface, unsigned node )
     starpu_cham_tile_interface_t *cham_tile_interface =
         (starpu_cham_tile_interface_t *) data_interface;
 
-#if defined(CHAMELEON_USE_HMAT)
+#if defined(CHAMELEON_USE_HMATOSS)
     if ( (cham_tile_interface->tile.format & CHAMELEON_TILE_HMAT) &&
          (cham_tile_interface->tile.mat != NULL ) )
     {
@@ -331,7 +331,7 @@ static int
 cti_pack_data_hmat( starpu_cham_tile_interface_t *cham_tile_interface,
                     void *ptr )
 {
-#if !defined(CHAMELEON_USE_HMAT)
+#if !defined(CHAMELEON_USE_HMATOSS)
     assert( 0 );
     (void)cham_tile_interface;
     (void)ptr;
@@ -432,7 +432,7 @@ cti_unpack_data_hmat( starpu_cham_tile_interface_t *cham_tile_interface,
                       void *ptr )
 {
     assert( cham_tile_interface->tile.format & CHAMELEON_TILE_HMAT );
-#if !defined(CHAMELEON_USE_HMAT)
+#if !defined(CHAMELEON_USE_HMATOSS)
     assert( 0 );
     (void)cham_tile_interface;
     (void)ptr;
diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt
index 21d7070e4..c9fc1b731 100644
--- a/testing/CMakeLists.txt
+++ b/testing/CMakeLists.txt
@@ -297,7 +297,7 @@ include(CTestLists.cmake)
 # copy input files
 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/input DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 
-if ( CHAMELEON_USE_HMAT AND (NOT CHAMELEON_SIMULATION) AND CHAMELEON_USE_MPI )
+if ( CHAMELEON_USE_HMATOSS AND (NOT CHAMELEON_SIMULATION) AND CHAMELEON_USE_MPI )
 
   add_subdirectory( test_fembem )
 
-- 
GitLab