From ca3b2021a36e7ef28d8dcec660de0292a6e96603 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Wed, 15 Jul 2020 14:47:12 +0200
Subject: [PATCH] Try to synchronize the wrapper generation with pastix

---
 tools/gen_wrappers.py                  | 21 +++++++++++++--------
 tools/wrappers/__init__.py             |  6 +++---
 tools/wrappers/wrap_fortran.py         | 13 +++++++------
 tools/wrappers/wrap_julia.py           | 19 ++++++++++++++-----
 tools/wrappers/wrap_python.py          | 13 +++++++------
 wrappers/fortran90/src/spm_enums.F90   |  6 +++---
 wrappers/fortran90/src/spmf.f90        |  6 +++---
 wrappers/julia/spm/src/spm.jl          | 17 +++++++++--------
 wrappers/julia/spm/src/spm_enums.jl.in |  4 ++--
 wrappers/python/CMakeLists.txt         |  4 ++--
 wrappers/python/spm/__spm__.py         |  6 +++---
 wrappers/python/spm/enum.py.in         |  8 ++++----
 12 files changed, 70 insertions(+), 53 deletions(-)

diff --git a/tools/gen_wrappers.py b/tools/gen_wrappers.py
index 403a4e43..b82c05ac 100755
--- a/tools/gen_wrappers.py
+++ b/tools/gen_wrappers.py
@@ -7,13 +7,13 @@
 
  @copyright 2016-2017 University of Tennessee, US, University of
                       Manchester, UK. All rights reserved.
- @copyright 2017-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2017-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
- @version 6.0.0
+ @version 6.1.0
  @author Pierre Ramet
  @author Mathieu Faverge
- @date 2017-05-04
+ @date 2020-01-21
 
 """
 import os
@@ -22,7 +22,7 @@ import argparse
 import wrappers
 
 description = '''\
-Generates Fortran 90 and Python wrappers from the spm header files.'''
+Generates Fortran 90 and Python wrappers from the spm and pastix header files.'''
 
 help = '''\
 ----------------------------------------------------------------------
@@ -44,7 +44,9 @@ parser.add_argument('args', nargs='*', action='store', help='Files to process')
 opts = parser.parse_args()
 
 # exclude inline functions from the interface
-exclude_list = [ "inline", "spmIntSort", "spmIntMSort" ]
+exclude_list = [ "inline", "spmIntSort", "spmIntMSort",
+                 "orderDraw", "orderSupernodes", "pastixOrderCompute", "pastixOrderApplyLevelOrder",
+                 "pastixOrderAddIsolate", "pastixOrderFindSupernodes" ]
 
 def polish_file(whole_file):
     """Preprocessing and cleaning of the header file.
@@ -57,6 +59,9 @@ def polish_file(whole_file):
     # Remove C comments:
     clean_file = re.sub(r"(?s)/\*.*?\*/", "", clean_file)
     clean_file = re.sub(r"//.*", "", clean_file)
+    # Remove BEGIN/END_C_DECLS statement:
+    clean_file = re.sub("BEGIN_C_DECLS", "", clean_file)
+    clean_file = re.sub("END_C_DECLS", "", clean_file)
     # Remove C directives (multilines then monoline):
     clean_file = re.sub(r"(?m)^#(.*[\\][\n])+.*?$", "", clean_file)
     clean_file = re.sub("(?m)^#.*$", "", clean_file)
@@ -469,7 +474,7 @@ spm_enums = {
                    'description' : "SPM python wrapper to define enums and datatypes",
                    'header'      : "# Start with __ to prevent broadcast to file importing enum\n"
                                    "__spm_int__ = @SPM_PYTHON_INTEGER@\n"
-                                   "__spm_mpi_enabled__ = @SPM_MPI_ENABLED@\n",
+                                   "__spm_mpi_enabled__ = @SPM_PYTHON_MPI_ENABLED@\n",
                    'footer'      : "",
                    'enums'       : { 'coeftype' : enums_python_coeftype,
                                      'mtxtype'  : "    SymPosDef = trans.ConjTrans + 1\n    HerPosDef = trans.ConjTrans + 2\n" }
@@ -492,7 +497,7 @@ spm_enums = {
     'julia'   : { 'filename'    : "wrappers/julia/spm/src/spm_enums.jl.in",
                   'description' : "SPM julia wrapper to define enums and datatypes",
                   'header'      :"const spm_int_t = @SPM_JULIA_INTEGER@\n"
-                                 "const spm_mpi_enabled = @SPM_MPI_ENABLED@\n",
+                                 "const spm_mpi_enabled = @SPM_JULIA_MPI_ENABLED@\n",
                   'footer'      : "",
                   'enums'       : {}
     },
@@ -540,7 +545,7 @@ spm = {
                                   "end\n"
                                   "libspm = spm_library_path()\n\n"
                                   "if spm_mpi_enabled\n"
-                                  "    using MPI\n    MPI.Init()\nend\n\n"
+                                  "    using MPI\nend\n\n"
                                   "function __get_mpi_type__()\n"
                                   "     if !spm_mpi_enabled\n"
                                   "         return Cint\n"
diff --git a/tools/wrappers/__init__.py b/tools/wrappers/__init__.py
index 17e01a2a..9b577363 100644
--- a/tools/wrappers/__init__.py
+++ b/tools/wrappers/__init__.py
@@ -6,12 +6,12 @@ Wrappers
 
  PaStiX wrapper generators module intialization
 
- @copyright 2017-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2017-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
- @version 6.0.0
+ @version 6.1.0
  @author Mathieu Faverge
- @date 2017-05-04
+ @date 2019-11-12
 
 """
 
diff --git a/tools/wrappers/wrap_fortran.py b/tools/wrappers/wrap_fortran.py
index e5ede65a..805b33ae 100644
--- a/tools/wrappers/wrap_fortran.py
+++ b/tools/wrappers/wrap_fortran.py
@@ -7,17 +7,18 @@ Wrapper Fortran 90
 
  PaStiX generator for the Fortran 90 wrapper
 
- @copyright 2017-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2017-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
- @version 6.0.0
+ @version 6.0.3
  @author Mathieu Faverge
- @date 2017-05-04
+ @date 2019-12-05
 
 """
 import os
 import re
 import argparse
+import time
 from . import *
 
 # set indentation in the f90 file
@@ -137,12 +138,12 @@ class wrap_fortran:
 !
 ! ''' + f['description'] + '''
 !
-! @copyright 2017      Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+! @copyright 2017-''' + time.strftime( "%Y" ) + ''' Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 !                      Univ. Bordeaux. All rights reserved.
 !
-! @version 6.0.0
+! @version 6.0.3
 ! @author Mathieu Faverge
-! @date 2017-01-01
+! @date ''' + time.strftime( "%Y-%m-%d" ) + '''
 !
 ! This file has been automatically generated with gen_wrappers.py
 !
diff --git a/tools/wrappers/wrap_julia.py b/tools/wrappers/wrap_julia.py
index 3d39fcce..b4dc3423 100644
--- a/tools/wrappers/wrap_julia.py
+++ b/tools/wrappers/wrap_julia.py
@@ -19,6 +19,7 @@ Wrapper Julia
 import os
 import re
 import argparse
+import time
 from . import *
 
 indent="    "
@@ -98,13 +99,13 @@ class wrap_julia:
 
  ''' + f['description'] + '''
 
- @copyright 2019-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2020-''' + time.strftime( "%Y" ) + ''' Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
  @version 6.0.0
  @author Mathieu Faverge
  @author Lebdaoui selmane
- @date 2020-06-18
+ @date ''' + time.strftime( "%Y-%m-%d" ) + '''
 
 This file has been automatically generated with gen_wrappers.py
 
@@ -127,13 +128,14 @@ This file has been automatically generated with gen_wrappers.py
            Translate it into constants."""
         ename  = enum[0]
         params = enum[1]
+
         # initialize a string with the fortran interface
         bib = ""
         Bib = ""
         if ("SPM" in f['description']):
             bib = "spm_"
             Bib = "Spm"
-        elif ("Pastix" in f['description']):
+        elif ("PaStiX" in f['description']):
             bib = "pastix_"
             Bib = "PASTIX"
         py_interface = "@cenum " + bib + ename + "_t " + "{\n"
@@ -142,8 +144,9 @@ This file has been automatically generated with gen_wrappers.py
         length=0
         for param in params:
             if ename == "mtxtype":
-                param[1] = re.sub(r"trans.", Bib, param[1])
+                param[1] = re.sub(r"trans.", "Spm", param[1])
             length = max( length, len(param[0]))
+
         fmt="%-"+ str(length) + "s"
 
         # loop over the arguments of the enum
@@ -240,6 +243,12 @@ This file has been automatically generated with gen_wrappers.py
                 func_line += ", "
             else :
                 func_line += " "
-        func_line+= ")::"+types_dict[return_type]
+
+        ret_val = types_dict[return_type]
+        if return_pointer == "*" :
+            ret_val   = "Ptr{"+types_dict[return_type]+"}"
+        elif  return_pointer == "**" :
+            ret_val   = "Ptr{Ptr{"+types_dict[return_type]+"}}"
+        func_line += ")::" + ret_val
         py_interface=cbinding_line + func_line + "\nend\n"
         return py_interface
diff --git a/tools/wrappers/wrap_python.py b/tools/wrappers/wrap_python.py
index 47d2c635..b1656ef7 100644
--- a/tools/wrappers/wrap_python.py
+++ b/tools/wrappers/wrap_python.py
@@ -7,17 +7,18 @@ Wrapper Python
 
  PaStiX generator for the python wrapper
 
- @copyright 2017-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2017-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
- @version 6.0.0
+ @version 6.0.3
  @author Mathieu Faverge
- @date 2017-05-04
+ @date 2019-12-05
 
 """
 import os
 import re
 import argparse
+import time
 from . import *
 
 indent="    "
@@ -134,14 +135,14 @@ class wrap_python:
 
  ''' + f['description'] + '''
 
- @copyright 2017-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2017-''' + time.strftime( "%Y" ) + ''' Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
- @version 6.0.0
+ @version 6.0.3
  @author Pierre Ramet
  @author Mathieu Faverge
  @author Louis Poirel
- @date 2017-05-04
+ @date ''' + time.strftime( "%Y-%m-%d" ) + '''
 
 This file has been automatically generated with gen_wrappers.py
 
diff --git a/wrappers/fortran90/src/spm_enums.F90 b/wrappers/fortran90/src/spm_enums.F90
index bcd328fb..03a480db 100644
--- a/wrappers/fortran90/src/spm_enums.F90
+++ b/wrappers/fortran90/src/spm_enums.F90
@@ -4,12 +4,12 @@
 !
 ! SPM fortran 90 wrapper to define enums and datatypes
 !
-! @copyright 2017      Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+! @copyright 2017-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 !                      Univ. Bordeaux. All rights reserved.
 !
-! @version 6.0.0
+! @version 6.0.3
 ! @author Mathieu Faverge
-! @date 2017-01-01
+! @date 2020-07-15
 !
 ! This file has been automatically generated with gen_wrappers.py
 !
diff --git a/wrappers/fortran90/src/spmf.f90 b/wrappers/fortran90/src/spmf.f90
index c13609ee..44c3677e 100644
--- a/wrappers/fortran90/src/spmf.f90
+++ b/wrappers/fortran90/src/spmf.f90
@@ -4,12 +4,12 @@
 !
 ! SPM Fortran 90 wrapper
 !
-! @copyright 2017      Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+! @copyright 2017-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 !                      Univ. Bordeaux. All rights reserved.
 !
-! @version 6.0.0
+! @version 6.0.3
 ! @author Mathieu Faverge
-! @date 2017-01-01
+! @date 2020-07-15
 !
 ! This file has been automatically generated with gen_wrappers.py
 !
diff --git a/wrappers/julia/spm/src/spm.jl b/wrappers/julia/spm/src/spm.jl
index b6fb1156..8a2f1676 100644
--- a/wrappers/julia/spm/src/spm.jl
+++ b/wrappers/julia/spm/src/spm.jl
@@ -4,17 +4,18 @@
 
  SPM julia wrapper
 
- @copyright 2019-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2020-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
  @version 6.0.0
  @author Mathieu Faverge
  @author Lebdaoui selmane
- @date 2020-06-18
+ @date 2020-07-15
 
 This file has been automatically generated with gen_wrappers.py
 
 =#
+
 module spm
 using CBinding
 using Libdl
@@ -79,7 +80,7 @@ end
 end
 
 @cbindings libspm begin
-    @cextern spmCopy( spm::Ptr{spmatrix_t} )::spmatrix_t
+    @cextern spmCopy( spm::Ptr{spmatrix_t} )::Ptr{spmatrix_t}
 end
 
 @cbindings libspm begin
@@ -107,11 +108,11 @@ end
 end
 
 @cbindings libspm begin
-    @cextern spmScatter( spm::Ptr{spmatrix_t}, n::spm_int_t, loc2glob::Ptr{spm_int_t}, distByColumn::Cint, root::Cint, comm::__get_mpi_type__() )::spmatrix_t
+    @cextern spmScatter( spm::Ptr{spmatrix_t}, n::spm_int_t, loc2glob::Ptr{spm_int_t}, distByColumn::Cint, root::Cint, comm::__get_mpi_type__() )::Ptr{spmatrix_t}
 end
 
 @cbindings libspm begin
-    @cextern spmGather( spm::Ptr{spmatrix_t}, root::Cint )::spmatrix_t
+    @cextern spmGather( spm::Ptr{spmatrix_t}, root::Cint )::Ptr{spmatrix_t}
 end
 
 @cbindings libspm begin
@@ -159,7 +160,7 @@ end
 end
 
 @cbindings libspm begin
-    @cextern spmIntConvert( n::spm_int_t, input::Ptr{Cint} )::spm_int_t
+    @cextern spmIntConvert( n::spm_int_t, input::Ptr{Cint} )::Ptr{spm_int_t}
 end
 
 @cbindings libspm begin
@@ -179,7 +180,7 @@ end
 end
 
 @cbindings libspm begin
-    @cextern spm2Dense( spm::Ptr{spmatrix_t} )::Cvoid
+    @cextern spm2Dense( spm::Ptr{spmatrix_t} )::Ptr{Cvoid}
 end
 
 @cbindings libspm begin
@@ -195,7 +196,7 @@ end
 end
 
 @cbindings libspm begin
-    @cextern spmDofExtend( spm::Ptr{spmatrix_t}, type::Cint, dof::Cint )::spmatrix_t
+    @cextern spmDofExtend( spm::Ptr{spmatrix_t}, type::Cint, dof::Cint )::Ptr{spmatrix_t}
 end
 
 end   #module
diff --git a/wrappers/julia/spm/src/spm_enums.jl.in b/wrappers/julia/spm/src/spm_enums.jl.in
index b57ec429..71e5bca1 100644
--- a/wrappers/julia/spm/src/spm_enums.jl.in
+++ b/wrappers/julia/spm/src/spm_enums.jl.in
@@ -4,13 +4,13 @@
 
  SPM julia wrapper to define enums and datatypes
 
- @copyright 2019-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2020-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
  @version 6.0.0
  @author Mathieu Faverge
  @author Lebdaoui selmane
- @date 2020-06-18
+ @date 2020-07-15
 
 This file has been automatically generated with gen_wrappers.py
 
diff --git a/wrappers/python/CMakeLists.txt b/wrappers/python/CMakeLists.txt
index 11a6bf87..80bfcb7b 100644
--- a/wrappers/python/CMakeLists.txt
+++ b/wrappers/python/CMakeLists.txt
@@ -17,9 +17,9 @@ else()
 endif()
 
 if (SPM_WITH_MPI)
-  set(SPM_MPI_ENABLED 1)
+  set(SPM_PYTHON_MPI_ENABLED 1)
 else()
-  set(SPM_MPI_ENABLED 0)
+  set(SPM_PYTHON_MPI_ENABLED 0)
 endif()
 
 configure_file(
diff --git a/wrappers/python/spm/__spm__.py b/wrappers/python/spm/__spm__.py
index aa8b70a7..421aee43 100644
--- a/wrappers/python/spm/__spm__.py
+++ b/wrappers/python/spm/__spm__.py
@@ -4,14 +4,14 @@
 
  SPM python wrapper
 
- @copyright 2017-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2017-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
- @version 6.0.0
+ @version 6.0.3
  @author Pierre Ramet
  @author Mathieu Faverge
  @author Louis Poirel
- @date 2017-05-04
+ @date 2020-07-15
 
 This file has been automatically generated with gen_wrappers.py
 
diff --git a/wrappers/python/spm/enum.py.in b/wrappers/python/spm/enum.py.in
index 80b547f9..988699d4 100644
--- a/wrappers/python/spm/enum.py.in
+++ b/wrappers/python/spm/enum.py.in
@@ -4,14 +4,14 @@
 
  SPM python wrapper to define enums and datatypes
 
- @copyright 2017-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ @copyright 2017-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
                       Univ. Bordeaux. All rights reserved.
 
- @version 6.0.0
+ @version 6.0.3
  @author Pierre Ramet
  @author Mathieu Faverge
  @author Louis Poirel
- @date 2017-05-04
+ @date 2020-07-15
 
 This file has been automatically generated with gen_wrappers.py
 
@@ -21,7 +21,7 @@ import numpy as np
 
 # Start with __ to prevent broadcast to file importing enum
 __spm_int__ = @SPM_PYTHON_INTEGER@
-__spm_mpi_enabled__ = @SPM_MPI_ENABLED@
+__spm_mpi_enabled__ = @SPM_PYTHON_MPI_ENABLED@
 
 class verbose:
     Not = 0
-- 
GitLab