Skip to content

MPI error when broadcasting strings #65

@austin-hoover

Description

@austin-hoover

I get an error when mpi broadcasting strings, but not arrays. The following script is adapted from here.

from orbit.core import orbit_mpi

mpi_comm = orbit_mpi.mpi_comm.MPI_COMM_WORLD
mpi_rank = orbit_mpi.MPI_Comm_rank(mpi_comm)
mpi_size = orbit_mpi.MPI_Comm_size(mpi_comm)

main_rank = 0

data = (1, 2, 3)
data_type = orbit_mpi.mpi_datatype.MPI_INT
data_new = orbit_mpi.MPI_Bcast(data, data_type, main_rank, mpi_comm)
print(f"rank={mpi_rank} data_new={data_new}")

data = (1.0, 2.0, 3.0)
data_type = orbit_mpi.mpi_datatype.MPI_DOUBLE
data_new = orbit_mpi.MPI_Bcast(data, data_type, main_rank, mpi_comm)
print(f"rank={mpi_rank} data_new={data_new}")

data = "test"
data_type = orbit_mpi.mpi_datatype.MPI_CHAR
data_new = orbit_mpi.MPI_Bcast(data, data_type, main_rank, mpi_comm)
print(f"rank={mpi_rank} data_new={data_new}")

The script fails on the third broadcast of the string "test".

(pyorbit-mpi) 46h@mac144229 MPI_Tests % mpirun -n 2 python test_mpi_bcast.py   
rank=0 data_new=(1, 2, 3)
rank=0 data_new=(1.0, 2.0, 3.0)
rank=1 data_new=(1, 2, 3)
rank=1 data_new=(1.0, 2.0, 3.0)
Traceback (most recent call last):
  File "/Users/46h/repo/pyorbit/examples/MPI_Tests/test_mpi_bcast.py", line 22, in <module>
Traceback (most recent call last):
  File "/Users/46h/repo/pyorbit/examples/MPI_Tests/test_mpi_bcast.py", line 22, in <module>
    data_new = orbit_mpi.MPI_Bcast(data, data_type, main_rank, mpi_comm)
    data_new = orbit_mpi.MPI_Bcast(data, data_type, main_rank, mpi_comm)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

PyORBIT version = 3.0.2.dev2+gb0cf39f.d20250501

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions