Example #1
0
    def __init__(self):
        lib = load_library('metis')

        # Try to determine the data types METIS was compiled with
        with silence():
            self._probe_types(lib)

        # METIS_SetDefaultOptions
        self.METIS_SetDefaultOptions = lib.METIS_SetDefaultOptions
        self.METIS_SetDefaultOptions.argtypes = [c_void_p]
        self.METIS_SetDefaultOptions.errcheck = self._errcheck

        # METIS_PartGraphKway
        self.METIS_PartGraphKway = lib.METIS_PartGraphKway
        self.METIS_PartGraphKway.argtypes = [
            POINTER(self.metis_int),
            POINTER(self.metis_int), c_void_p, c_void_p, c_void_p, c_void_p,
            c_void_p,
            POINTER(self.metis_int), c_void_p, c_void_p, c_void_p,
            POINTER(self.metis_int), c_void_p
        ]
        self.METIS_PartGraphKway.errcheck = self._errcheck

        # METIS_PartGraphRecursive
        self.METIS_PartGraphRecursive = lib.METIS_PartGraphRecursive
        self.METIS_PartGraphRecursive.argtypes = [
            POINTER(self.metis_int),
            POINTER(self.metis_int), c_void_p, c_void_p, c_void_p, c_void_p,
            c_void_p,
            POINTER(self.metis_int), c_void_p, c_void_p, c_void_p,
            POINTER(self.metis_int), c_void_p
        ]
        self.METIS_PartGraphRecursive.errcheck = self._errcheck
Example #2
0
    def __init__(self):
        lib = load_library('metis')

        # Try to determine the data types METIS was compiled with
        with silence():
            self._probe_types(lib)

        # METIS_SetDefaultOptions
        self.METIS_SetDefaultOptions = lib.METIS_SetDefaultOptions
        self.METIS_SetDefaultOptions.argtypes = [c_void_p]
        self.METIS_SetDefaultOptions.errcheck = self._errcheck

        # METIS_PartGraphKway
        self.METIS_PartGraphKway = lib.METIS_PartGraphKway
        self.METIS_PartGraphKway.argtypes = [
            POINTER(self.metis_int), POINTER(self.metis_int),
            c_void_p, c_void_p, c_void_p, c_void_p, c_void_p,
            POINTER(self.metis_int), c_void_p, c_void_p, c_void_p,
            POINTER(self.metis_int), c_void_p
        ]
        self.METIS_PartGraphKway.errcheck = self._errcheck

        # METIS_PartGraphRecursive
        self.METIS_PartGraphRecursive = lib.METIS_PartGraphRecursive
        self.METIS_PartGraphRecursive.argtypes = [
            POINTER(self.metis_int), POINTER(self.metis_int),
            c_void_p, c_void_p, c_void_p, c_void_p, c_void_p,
            POINTER(self.metis_int), c_void_p, c_void_p, c_void_p,
            POINTER(self.metis_int), c_void_p
        ]
        self.METIS_PartGraphRecursive.errcheck = self._errcheck
Example #3
0
    def __init__(self):
        lib = load_library('clblast')

        # Constants
        self.CLBlastLayoutRowMajor = 101
        self.CLBlastLayoutColMajor = 102
        self.CLBlastTransposeNo = 111
        self.CLBlastTransposeYes = 112

        # CLBlastSgemm
        self.CLBlastSgemm = lib.CLBlastSgemm
        self.CLBlastSgemm.argtypes = [
            c_int, c_int, c_int, c_size_t, c_size_t, c_size_t, c_float,
            c_void_p, c_size_t, c_size_t, c_void_p, c_size_t, c_size_t,
            c_float, c_void_p, c_size_t, c_size_t,
            POINTER(c_void_p), c_void_p
        ]
        self.CLBlastSgemm.errcheck = self._errcheck

        # CLBlastDgemm
        self.CLBlastDgemm = lib.CLBlastDgemm
        self.CLBlastDgemm.argtypes = [
            c_int, c_int, c_int, c_size_t, c_size_t, c_size_t, c_double,
            c_void_p, c_size_t, c_size_t, c_void_p, c_size_t, c_size_t,
            c_double, c_void_p, c_size_t, c_size_t,
            POINTER(c_void_p), c_void_p
        ]
        self.CLBlastDgemm.errcheck = self._errcheck
Example #4
0
    def __init__(self):
        lib = load_library('cublas')

        # Constants
        self.CUBLAS_OP_N = 0
        self.CUBLAS_OP_T = 1
        self.CUBLAS_OP_C = 2

        # cublasCreate
        self.cublasCreate = lib.cublasCreate_v2
        self.cublasCreate.argtypes = [POINTER(c_void_p)]
        self.cublasCreate.errcheck = self._errcheck

        # cublasDestroy
        self.cublasDestroy = lib.cublasDestroy_v2
        self.cublasDestroy.argtypes = [c_void_p]
        self.cublasDestroy.errcheck = self._errcheck

        # cublasSetStream
        self.cublasSetStream = lib.cublasSetStream_v2
        self.cublasSetStream.argtypes = [c_void_p, c_void_p]
        self.cublasSetStream.errcheck = self._errcheck

        # cublasDgemm
        self.cublasDgemm = lib.cublasDgemm_v2
        self.cublasDgemm.argtypes = [
            c_void_p, c_int, c_int, c_int, c_int, c_int,
            POINTER(c_double), c_void_p, c_int, c_void_p, c_int,
            POINTER(c_double), c_void_p, c_int
        ]
        self.cublasDgemm.errcheck = self._errcheck

        # cublasSgemm
        self.cublasSgemm = lib.cublasSgemm_v2
        self.cublasSgemm.argtypes = [
            c_void_p, c_int, c_int, c_int, c_int, c_int,
            POINTER(c_float), c_void_p, c_int, c_void_p, c_int,
            POINTER(c_float), c_void_p, c_int
        ]
        self.cublasSgemm.errcheck = self._errcheck

        # cublasDnrm2
        self.cublasDnrm2 = lib.cublasDnrm2_v2
        self.cublasDnrm2.argtypes = [
            c_void_p, c_int, c_void_p, c_int, POINTER(c_double)
        ]
        self.cublasDnrm2.errcheck = self._errcheck

        # cublasSnrm2
        self.cublasSnrm2 = lib.cublasSnrm2_v2
        self.cublasSnrm2.argtypes = [
            c_void_p, c_int, c_void_p, c_int, POINTER(c_float)
        ]
        self.cublasSnrm2.errcheck = self._errcheck
Example #5
0
File: xsmm.py Project: pv101/PyFR
    def __init__(self):
        lib = load_library('xsmm')

        # libxsmm_init
        self.libxsmm_init = lib.libxsmm_init
        self.libxsmm_init.argtypes = []
        self.libxsmm_init.restype = None

        # libxsmm_finalize
        self.libxsmm_finalize = lib.libxsmm_finalize
        self.libxsmm_finalize.argtypes = []
        self.libxsmm_finalize.restype = None

        # libxsmm_dfsspmdm_create
        self.libxsmm_dfsspmdm_create = lib.libxsmm_dfsspmdm_create
        self.libxsmm_dfsspmdm_create.argtypes = [
            c_int, c_int, c_int, c_int, c_int, c_int,
            c_double, c_double, c_void_p
        ]
        self.libxsmm_dfsspmdm_create.restype = c_void_p

        # libxsmm_sfsspmdm_create
        self.libxsmm_sfsspmdm_create = lib.libxsmm_sfsspmdm_create
        self.libxsmm_sfsspmdm_create.argtypes = [
            c_int, c_int, c_int, c_int, c_int, c_int,
            c_float, c_float, c_void_p
        ]
        self.libxsmm_sfsspmdm_create.restype = c_void_p

        # libxsmm_dfsspmdm_execute
        self.libxsmm_dfsspmdm_execute = lib.libxsmm_dfsspmdm_execute
        self.libxsmm_dfsspmdm_execute.argtypes = [
            c_void_p, c_void_p, c_void_p
        ]
        self.libxsmm_dfsspmdm_execute.restype = None

        # libxsmm_sfsspmdm_execute
        self.libxsmm_sfsspmdm_execute = lib.libxsmm_sfsspmdm_execute
        self.libxsmm_sfsspmdm_execute.argtypes = [
            c_void_p, c_void_p, c_void_p
        ]
        self.libxsmm_sfsspmdm_execute.restype = None

        # libxsmm_dfsspmdm_destroy
        self.libxsmm_dfsspmdm_destroy = lib.libxsmm_dfsspmdm_destroy
        self.libxsmm_dfsspmdm_destroy.argtypes = [c_void_p]
        self.libxsmm_dfsspmdm_destroy.restype = None

        # libxsmm_sfsspmdm_destroy
        self.libxsmm_sfsspmdm_destroy = lib.libxsmm_sfsspmdm_destroy
        self.libxsmm_sfsspmdm_destroy.argtypes = [c_void_p]
        self.libxsmm_sfsspmdm_destroy.restype = None
Example #6
0
File: xsmm.py Project: yifanb/PyFR
    def __init__(self):
        lib = load_library('xsmm')

        # libxsmm_init
        self.libxsmm_init = lib.libxsmm_init
        self.libxsmm_init.argtypes = []
        self.libxsmm_init.restype = None

        # libxsmm_finalize
        self.libxsmm_finalize = lib.libxsmm_finalize
        self.libxsmm_finalize.argtypes = []
        self.libxsmm_finalize.restype = None

        # libxsmm_dfsspmdm_create
        self.libxsmm_dfsspmdm_create = lib.libxsmm_dfsspmdm_create
        self.libxsmm_dfsspmdm_create.argtypes = [
            c_int, c_int, c_int, c_int, c_int, c_int, c_double, c_double,
            c_void_p
        ]
        self.libxsmm_dfsspmdm_create.restype = c_void_p

        # libxsmm_sfsspmdm_create
        self.libxsmm_sfsspmdm_create = lib.libxsmm_sfsspmdm_create
        self.libxsmm_sfsspmdm_create.argtypes = [
            c_int, c_int, c_int, c_int, c_int, c_int, c_float, c_float,
            c_void_p
        ]
        self.libxsmm_sfsspmdm_create.restype = c_void_p

        # libxsmm_dfsspmdm_execute
        self.libxsmm_dfsspmdm_execute = lib.libxsmm_dfsspmdm_execute
        self.libxsmm_dfsspmdm_execute.argtypes = [c_void_p, c_void_p, c_void_p]
        self.libxsmm_dfsspmdm_execute.restype = None

        # libxsmm_sfsspmdm_execute
        self.libxsmm_sfsspmdm_execute = lib.libxsmm_sfsspmdm_execute
        self.libxsmm_sfsspmdm_execute.argtypes = [c_void_p, c_void_p, c_void_p]
        self.libxsmm_sfsspmdm_execute.restype = None

        # libxsmm_dfsspmdm_destroy
        self.libxsmm_dfsspmdm_destroy = lib.libxsmm_dfsspmdm_destroy
        self.libxsmm_dfsspmdm_destroy.argtypes = [c_void_p]
        self.libxsmm_dfsspmdm_destroy.restype = None

        # libxsmm_sfsspmdm_destroy
        self.libxsmm_sfsspmdm_destroy = lib.libxsmm_sfsspmdm_destroy
        self.libxsmm_sfsspmdm_destroy.argtypes = [c_void_p]
        self.libxsmm_sfsspmdm_destroy.restype = None
Example #7
0
    def __init__(self):
        lib = load_library('clBLAS')

        # Constants
        self.clblasRowMajor = 0
        self.clblasColumnMajor = 1
        self.clblasNoTrans = 0
        self.clblasTrans = 1
        self.clblasConjTrans = 2

        # clblasSetup
        self.clblasSetup = lib.clblasSetup
        self.clblasSetup.argtypes = []
        self.clblasSetup.errcheck = self._errcheck

        # clblasTeardown
        self.clblasTeardown = lib.clblasTeardown
        self.clblasTeardown.argtypes = []
        self.clblasTeardown.restype = None

        # clblasSgemm
        self.clblasSgemm = lib.clblasSgemm
        self.clblasSgemm.argtypes = [
            c_int, c_int, c_int, c_size_t, c_size_t, c_size_t, c_float,
            c_void_p, c_size_t, c_size_t, c_void_p, c_size_t, c_size_t,
            c_float, c_void_p, c_size_t, c_size_t, c_uint,
            POINTER(c_void_p), c_uint,
            POINTER(c_void_p),
            POINTER(c_void_p)
        ]
        self.clblasSgemm.errcheck = self._errcheck

        # clblasDgemm
        self.clblasDgemm = lib.clblasDgemm
        self.clblasDgemm.argtypes = [
            c_int, c_int, c_int, c_size_t, c_size_t, c_size_t, c_double,
            c_void_p, c_size_t, c_size_t, c_void_p, c_size_t, c_size_t,
            c_double, c_void_p, c_size_t, c_size_t, c_uint,
            POINTER(c_void_p), c_uint,
            POINTER(c_void_p),
            POINTER(c_void_p)
        ]
        self.clblasDgemm.errcheck = self._errcheck
Example #8
0
    def __init__(self):
        lib = load_library('clBLAS')

        # Constants
        self.clblasRowMajor = 0
        self.clblasColumnMajor = 1
        self.clblasNoTrans = 0
        self.clblasTrans = 1
        self.clblasConjTrans = 2

        # clblasSetup
        self.clblasSetup = lib.clblasSetup
        self.clblasSetup.argtypes = []
        self.clblasSetup.errcheck = self._errcheck

        # clblasTeardown
        self.clblasTeardown = lib.clblasTeardown
        self.clblasTeardown.argtypes = []
        self.clblasTeardown.restype = None

        # clblasSgemm
        self.clblasSgemm = lib.clblasSgemm
        self.clblasSgemm.argtypes = [
            c_int, c_int, c_int,  c_size_t, c_size_t, c_size_t,
            c_float, c_void_p, c_size_t, c_size_t,
            c_void_p, c_size_t, c_size_t, c_float,
            c_void_p, c_size_t, c_size_t,
            c_uint, POINTER(c_void_p),
            c_uint, POINTER(c_void_p), POINTER(c_void_p)
        ]
        self.clblasSgemm.errcheck = self._errcheck

        # clblasDgemm
        self.clblasDgemm = lib.clblasDgemm
        self.clblasDgemm.argtypes = [
            c_int, c_int, c_int, c_size_t, c_size_t, c_size_t,
            c_double, c_void_p, c_size_t, c_size_t,
            c_void_p, c_size_t, c_size_t, c_double,
            c_void_p, c_size_t, c_size_t,
            c_uint, POINTER(c_void_p),
            c_uint, POINTER(c_void_p), POINTER(c_void_p)
        ]
        self.clblasDgemm.errcheck = self._errcheck
Example #9
0
File: cgns.py Project: Kiiree/PyFR
    def __init__(self):
        # Load CGNS 3.3+
        # Previous version may yield undefined symbols from HDF5.
        # Develop branch after the commit (e0faea6) fixes this issue.
        self.lib = lib = load_library('cgns')

        # Constants (from cgnslib.h)
        self.CG_MODE_READ = 0
        self.RealDouble = 4
        self.Unstructured = 3
        self.PointRange, self.ElementRange = 4, 6

        # cg_open
        lib.cg_open.argtypes = [c_char_p, c_int, POINTER(c_int)]
        lib.cg_open.errcheck = self._errcheck

        # cg_close
        lib.cg_close.argtypes = [c_int]
        lib.cg_close.errcheck = self._errcheck

        # cg_nbases
        lib.cg_nbases.argtypes = [c_int, POINTER(c_int)]
        lib.cg_nbases.errcheck = self._errcheck

        # cg_base_read
        lib.cg_base_read.argtypes = [c_int, c_int, c_char_p, POINTER(c_int),
                                     POINTER(c_int)]
        lib.cg_base_read.errcheck = self._errcheck

        # cg_nzones
        lib.cg_nzones.argtypes = [c_int, c_int, POINTER(c_int)]
        lib.cg_nzones.errcheck = self._errcheck

        # cg_zone_read
        lib.cg_zone_read.argtypes = [c_int, c_int, c_int, c_char_p,
                                     POINTER(c_int)]
        lib.cg_zone_read.errcheck = self._errcheck

        # cg_zone_type
        lib.cg_zone_type.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_zone_type.errcheck = self._errcheck

        # cg_coord_read
        lib.cg_coord_read.argtypes = [
            c_int, c_int, c_int, c_char_p, c_int, POINTER(c_int),
            POINTER(c_int), c_void_p
        ]
        lib.cg_coord_read.errcheck = self._errcheck

        # cg_nbocos
        lib.cg_nbocos.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_nbocos.errcheck = self._errcheck

        # cg_boco_info
        lib.cg_boco_info.argtypes = [
            c_int, c_int, c_int, c_int, c_char_p, POINTER(c_int),
            POINTER(c_int), POINTER(c_int), POINTER(c_int),
            POINTER(c_int), POINTER(c_int), POINTER(c_int)
        ]
        lib.cg_boco_info.errcheck = self._errcheck

        # cg_boco_read
        lib.cg_boco_read.argtypes = [c_int, c_int, c_int, c_int,
                                     POINTER(c_int), c_void_p]
        lib.cg_boco_read.errcheck = self._errcheck

        # cg_nsections
        lib.cg_nsections.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_nsections.errcheck = self._errcheck

        # cg_section_read
        lib.cg_section_read.argtypes = [
            c_int, c_int, c_int, c_int, c_char_p, POINTER(c_int),
            POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int)
        ]
        lib.cg_section_read.errcheck = self._errcheck

        # cg_ElementDataSize
        lib.cg_ElementDataSize.argtypes = [c_int, c_int, c_int, c_int,
                                           POINTER(c_int)]
        lib.cg_ElementDataSize.errcheck = self._errcheck

        # cg_elements_read
        lib.cg_elements_read.argtypes = [c_int, c_int, c_int, c_int,
                                         c_void_p, c_void_p]
        lib.cg_elements_read.errcheck = self._errcheck
Example #10
0
    def __init__(self):
        # Load CGNS
        self.lib = lib = load_library('cgns')

        # Constants (from cgnslib.h)
        self.CG_MODE_READ = 0
        self.RealDouble = 4
        self.Unstructured = 3
        self.PointRange, self.ElementRange = 4, 6

        # cg_open
        lib.cg_open.argtypes = [c_char_p, c_int, POINTER(c_int)]
        lib.cg_open.errcheck = self._errcheck

        # cg_close
        lib.cg_close.argtypes = [c_int]
        lib.cg_close.errcheck = self._errcheck

        # cg_base_read
        lib.cg_base_read.argtypes = [
            c_int, c_int, c_char_p,
            POINTER(c_int),
            POINTER(c_int)
        ]
        lib.cg_base_read.errcheck = self._errcheck

        # cg_nzones
        lib.cg_nzones.argtypes = [c_int, c_int, POINTER(c_int)]
        lib.cg_nzones.errcheck = self._errcheck

        # cg_zone_read
        lib.cg_zone_read.argtypes = [
            c_int, c_int, c_int, c_char_p,
            POINTER(c_int)
        ]
        lib.cg_zone_read.errcheck = self._errcheck

        # cg_zone_type
        lib.cg_zone_type.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_zone_type.errcheck = self._errcheck

        # cg_coord_read
        lib.cg_coord_read.argtypes = [
            c_int, c_int, c_int, c_char_p, c_int,
            POINTER(c_int),
            POINTER(c_int), c_void_p
        ]
        lib.cg_coord_read.errcheck = self._errcheck

        # cg_nbocos
        lib.cg_nbocos.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_nbocos.errcheck = self._errcheck

        # cg_boco_info
        lib.cg_boco_info.argtypes = [
            c_int, c_int, c_int, c_int, c_char_p,
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int)
        ]
        lib.cg_boco_info.errcheck = self._errcheck

        # cg_boco_read
        lib.cg_boco_read.argtypes = [
            c_int, c_int, c_int, c_int,
            POINTER(c_int), c_void_p
        ]
        lib.cg_boco_read.errcheck = self._errcheck

        # cg_nsections
        lib.cg_nsections.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_nsections.errcheck = self._errcheck

        # cg_section_read
        lib.cg_section_read.argtypes = [
            c_int, c_int, c_int, c_int, c_char_p,
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int)
        ]
        lib.cg_section_read.errcheck = self._errcheck

        # cg_ElementDataSize
        lib.cg_ElementDataSize.argtypes = [
            c_int, c_int, c_int, c_int,
            POINTER(c_int)
        ]
        lib.cg_ElementDataSize.errcheck = self._errcheck

        # cg_elements_read
        lib.cg_elements_read.argtypes = [
            c_int, c_int, c_int, c_int, c_void_p, c_void_p
        ]
        lib.cg_elements_read.errcheck = self._errcheck
Example #11
0
    def __init__(self):
        lib = load_library('scotch')

        # Types
        self.SCOTCH_Arch = SCOTCH_Arch = c_double*128
        self.SCOTCH_Graph = SCOTCH_Graph = c_double*128
        self.SCOTCH_Strat = SCOTCH_Strat = c_double*128

        # SCOTCH_archInit
        self.SCOTCH_archInit = lib.SCOTCH_archInit
        self.SCOTCH_archInit.argtypes = [POINTER(SCOTCH_Arch)]
        self.SCOTCH_archInit.errcheck = self._errcheck

        # SCOTCH_archExit
        self.SCOTCH_archExit = lib.SCOTCH_archExit
        self.SCOTCH_archExit.argtypes = [POINTER(SCOTCH_Arch)]
        self.SCOTCH_archExit.restype = None

        # SCOTCH_archCmpltw
        self.SCOTCH_archCmpltw = lib.SCOTCH_archCmpltw
        self.SCOTCH_archCmpltw.argtypes = [
            POINTER(SCOTCH_Arch), c_int, c_void_p
        ]
        self.SCOTCH_archCmpltw.errcheck = self._errcheck

        # SCOTCH_graphInit
        self.SCOTCH_graphInit = lib.SCOTCH_graphInit
        self.SCOTCH_graphInit.argtypes = [POINTER(SCOTCH_Graph)]
        self.SCOTCH_graphInit.errcheck = self._errcheck

        # SCOTCH_graphExit
        self.SCOTCH_graphExit = lib.SCOTCH_graphExit
        self.SCOTCH_graphExit.argtypes = [POINTER(SCOTCH_Graph)]
        self.SCOTCH_graphExit.restype = None

        # SCOTCH_graphBuild
        self.SCOTCH_graphBuild = lib.SCOTCH_graphBuild
        self.SCOTCH_graphBuild.argtypes = [
            POINTER(SCOTCH_Graph), c_int, c_int,
            c_void_p, c_void_p, c_void_p, c_void_p,
            c_int, c_void_p, c_void_p
        ]
        self.SCOTCH_graphBuild.errcheck = self._errcheck

        # SCOTCH_graphPart
        self.SCOTCH_graphMap = lib.SCOTCH_graphMap
        self.SCOTCH_graphMap.argtypes = [
            POINTER(SCOTCH_Graph), POINTER(SCOTCH_Arch),
            POINTER(SCOTCH_Strat), c_void_p
        ]
        self.SCOTCH_graphMap.errcheck = self._errcheck

        # SCOTCH_stratInit
        self.SCOTCH_stratInit = lib.SCOTCH_stratInit
        self.SCOTCH_stratInit.argtypes = [POINTER(SCOTCH_Strat)]
        self.SCOTCH_stratInit.errcheck = self._errcheck

        # SCOTCH_stratExit
        self.SCOTCH_stratExit = lib.SCOTCH_stratExit
        self.SCOTCH_stratExit.argtypes = [POINTER(SCOTCH_Strat)]
        self.SCOTCH_stratExit.restype = None

        # SCOTCH_stratGraphMapBuild
        self.SCOTCH_stratGraphMapBuild = lib.SCOTCH_stratGraphMapBuild
        self.SCOTCH_stratGraphMapBuild.argtypes = [
            POINTER(SCOTCH_Strat), c_int, c_int, c_double
        ]
        self.SCOTCH_stratGraphMapBuild.errcheck = self._errcheck
Example #12
0
File: cgns.py Project: jgiret/PyFR
    def __init__(self):
        # Load CGNS 3.3+
        # Previous version may yield undefined symbols from HDF5.
        # Develop branch after the commit (e0faea6) fixes this issue.
        self.lib = lib = load_library('cgns')

        # Constants (from cgnslib.h)
        self.CG_MODE_READ = 0
        self.RealDouble = 4
        self.Unstructured = 3
        self.PointRange, self.ElementRange = 4, 6

        # cg_open
        lib.cg_open.argtypes = [c_char_p, c_int, POINTER(c_int)]
        lib.cg_open.errcheck = self._errcheck

        # cg_close
        lib.cg_close.argtypes = [c_int]
        lib.cg_close.errcheck = self._errcheck

        # cg_nbases
        lib.cg_nbases.argtypes = [c_int, POINTER(c_int)]
        lib.cg_nbases.errcheck = self._errcheck

        # cg_base_read
        lib.cg_base_read.argtypes = [
            c_int, c_int, c_char_p,
            POINTER(c_int),
            POINTER(c_int)
        ]
        lib.cg_base_read.errcheck = self._errcheck

        # cg_nzones
        lib.cg_nzones.argtypes = [c_int, c_int, POINTER(c_int)]
        lib.cg_nzones.errcheck = self._errcheck

        # cg_zone_read
        lib.cg_zone_read.argtypes = [
            c_int, c_int, c_int, c_char_p,
            POINTER(c_int)
        ]
        lib.cg_zone_read.errcheck = self._errcheck

        # cg_zone_type
        lib.cg_zone_type.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_zone_type.errcheck = self._errcheck

        # cg_coord_read
        lib.cg_coord_read.argtypes = [
            c_int, c_int, c_int, c_char_p, c_int,
            POINTER(c_int),
            POINTER(c_int), c_void_p
        ]
        lib.cg_coord_read.errcheck = self._errcheck

        # cg_nbocos
        lib.cg_nbocos.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_nbocos.errcheck = self._errcheck

        # cg_boco_info
        lib.cg_boco_info.argtypes = [
            c_int, c_int, c_int, c_int, c_char_p,
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int)
        ]
        lib.cg_boco_info.errcheck = self._errcheck

        # cg_boco_read
        lib.cg_boco_read.argtypes = [
            c_int, c_int, c_int, c_int,
            POINTER(c_int), c_void_p
        ]
        lib.cg_boco_read.errcheck = self._errcheck

        # cg_nsections
        lib.cg_nsections.argtypes = [c_int, c_int, c_int, POINTER(c_int)]
        lib.cg_nsections.errcheck = self._errcheck

        # cg_section_read
        lib.cg_section_read.argtypes = [
            c_int, c_int, c_int, c_int, c_char_p,
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int),
            POINTER(c_int)
        ]
        lib.cg_section_read.errcheck = self._errcheck

        # cg_ElementDataSize
        lib.cg_ElementDataSize.argtypes = [
            c_int, c_int, c_int, c_int,
            POINTER(c_int)
        ]
        lib.cg_ElementDataSize.errcheck = self._errcheck

        # cg_elements_read
        lib.cg_elements_read.argtypes = [
            c_int, c_int, c_int, c_int, c_void_p, c_void_p
        ]
        lib.cg_elements_read.errcheck = self._errcheck
Example #13
0
    def __init__(self):
        lib = load_library('scotch')

        # Types
        self.SCOTCH_Arch = SCOTCH_Arch = c_double*128
        self.SCOTCH_Graph = SCOTCH_Graph = c_double*128
        self.SCOTCH_Strat = SCOTCH_Strat = c_double*128

        # SCOTCH_archInit
        self.SCOTCH_archInit = lib.SCOTCH_archInit
        self.SCOTCH_archInit.argtypes = [POINTER(SCOTCH_Arch)]
        self.SCOTCH_archInit.errcheck = self._errcheck

        # SCOTCH_archExit
        self.SCOTCH_archExit = lib.SCOTCH_archExit
        self.SCOTCH_archExit.argtypes = [POINTER(SCOTCH_Arch)]
        self.SCOTCH_archExit.restype = None

        # SCOTCH_archCmpltw
        self.SCOTCH_archCmpltw = lib.SCOTCH_archCmpltw
        self.SCOTCH_archCmpltw.argtypes = [
            POINTER(SCOTCH_Arch), c_int, c_void_p
        ]
        self.SCOTCH_archCmpltw.errcheck = self._errcheck

        # SCOTCH_graphInit
        self.SCOTCH_graphInit = lib.SCOTCH_graphInit
        self.SCOTCH_graphInit.argtypes = [POINTER(SCOTCH_Graph)]
        self.SCOTCH_graphInit.errcheck = self._errcheck

        # SCOTCH_graphExit
        self.SCOTCH_graphExit = lib.SCOTCH_graphExit
        self.SCOTCH_graphExit.argtypes = [POINTER(SCOTCH_Graph)]
        self.SCOTCH_graphExit.restype = None

        # SCOTCH_graphBuild
        self.SCOTCH_graphBuild = lib.SCOTCH_graphBuild
        self.SCOTCH_graphBuild.argtypes = [
            POINTER(SCOTCH_Graph), c_int, c_int,
            c_void_p, c_void_p, c_void_p, c_void_p,
            c_int, c_void_p, c_void_p
        ]
        self.SCOTCH_graphBuild.errcheck = self._errcheck

        # SCOTCH_graphPart
        self.SCOTCH_graphMap = lib.SCOTCH_graphMap
        self.SCOTCH_graphMap.argtypes = [
            POINTER(SCOTCH_Graph), POINTER(SCOTCH_Arch),
            POINTER(SCOTCH_Strat), c_void_p
        ]
        self.SCOTCH_graphMap.errcheck = self._errcheck

        # SCOTCH_stratInit
        self.SCOTCH_stratInit = lib.SCOTCH_stratInit
        self.SCOTCH_stratInit.argtypes = [POINTER(SCOTCH_Strat)]
        self.SCOTCH_stratInit.errcheck = self._errcheck

        # SCOTCH_stratExit
        self.SCOTCH_stratExit = lib.SCOTCH_stratExit
        self.SCOTCH_stratExit.argtypes = [POINTER(SCOTCH_Strat)]
        self.SCOTCH_stratExit.restype = None

        # SCOTCH_stratGraphMapBuild
        self.SCOTCH_stratGraphMapBuild = lib.SCOTCH_stratGraphMapBuild
        self.SCOTCH_stratGraphMapBuild.argtypes = [
            POINTER(SCOTCH_Strat), c_int, c_int, c_double
        ]
        self.SCOTCH_stratGraphMapBuild.errcheck = self._errcheck