Skip to main content

Python wrapper for dynamically loaded ScaLAPACK and BLACS libraries

Project description

Dynamic ScaLAPACK wrapper for Python

Python wrapper for dynamically loaded ScaLAPACK and BLACS libraries

from scalapack4py import ScaLAPACK4py, parprint, ordprint
from ctypes import cast, py_object, CDLL, RTLD_GLOBAL

scalapack_lib = CDLL('libscalapack-openmpi.so.2.0', mode=RTLD_GLOBAL)
sl = ScaLAPACK4py(scalapack_lib)


descr = sl.wrap_blacs_desc(descr)
locshape = (descr.locrow, descr.loccol)
data = np.ctypeslib.as_array(data, shape=locshape)
sl.scatter(data_src, descr, data)

Or

# run as:  mpiexec -n 2 python3 -u test_scatter_complex.py
import numpy as np, os
from mpi4py import MPI
from scalapack4py import ScaLAPACK4py
from ctypes import CDLL, RTLD_GLOBAL, POINTER, c_int, c_double

sl = ScaLAPACK4py(CDLL('libscalapack-openmpi.so.2.0', mode=RTLD_GLOBAL))

n = 5
dtype=np.complex128
a = np.arange(n*n, dtype=dtype).reshape((n,n), order='F') * (MPI.COMM_WORLD.rank+1) if MPI.COMM_WORLD.rank==0 else None

print (a)

MP, NP = 2,1

ctx = sl.make_blacs_context(sl.get_default_system_context(), MP, NP)
descr = sl.make_blacs_desc(ctx, n, n)
print("descr", descr, descr.locrow, descr.loccol)

b = np.zeros((descr.locrow, descr.loccol), dtype=dtype)

sl.scatter_numpy(a, POINTER(c_int)(descr), b.ctypes.data_as(POINTER(c_double)), b.dtype)
print (b)


c = sl.gather_numpy(POINTER(c_int)(descr), b, (n, n))
print (c)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scalapack4py-0.0.9.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scalapack4py-0.0.9-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file scalapack4py-0.0.9.tar.gz.

File metadata

  • Download URL: scalapack4py-0.0.9.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.1

File hashes

Hashes for scalapack4py-0.0.9.tar.gz
Algorithm Hash digest
SHA256 1580751eb3e9030c6b71109c22a1c55e2e742939066a382f2368bfc9b2162198
MD5 d881129b5daae82fee4d4ca313a9bcb8
BLAKE2b-256 71e13ed7167d9640c5e053ef3d87546a9ddde3217c9ab33f58dd3c8d92a53745

See more details on using hashes here.

File details

Details for the file scalapack4py-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: scalapack4py-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.1

File hashes

Hashes for scalapack4py-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d51dfa8e67a840174e8feb27e44130bdb7d99301f6f453db3a9e8fd7d5811cc6
MD5 414247f93a6fc1e386b0ea7c9dc880a7
BLAKE2b-256 8db73a0eadfc82b8de7ad27f44fe5f8d67acb75caeec2caa47a6b80add113bb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page