Skip to content

Ph4 gpu crashes when the number of particles exceeds 2^17 #1208

@ErwanH29

Description

@ErwanH29

Describe the bug
When trying to simulate more than 2^17 particles, Ph4 crashes in mode GPU.

To Reproduce

from amuse.lab import nbody_system, new_plummer_model, units
import natsort
import glob

from amuse.community.ph4.interface import Ph4

for n in [2**17, 2**17 + 1]:
    converter = nbody_system.nbody_to_si(10000 | units.MSun, 1 | units.pc)
    p = new_plummer_model(n, convert_nbody=converter)

    code = Ph4(converter, mode="gpu")
    code.particles.add_particles(p)

    channel_a = code.particles.new_channel_to(p)
    channel_b = p.new_channel_to(code.particles)
    print("# Particles: ", len(code.particles))
    channel_a.copy()
    print("Code to Local works")
    channel_b.copy()
    print("Local to Code works")
    code.stop()

The first iteration will work, the second will throw an error.

Logs

wrapped<wrapped<wrapped<wrapped<function: int get_state(int index_of_the_particle)
output: double mass, double x, double y, double z, double vx, double vy, double vz, double radius, int __result>>>>
Traceback (most recent call last):
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/rfi/core.py", line 129, in __call__
    dtype_to_result = self.interface.channel.recv_message(
        call_id, self.specification.id, handle_as_array
    )
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/rfi/channel.py", line 1361, in recv_message
    raise exceptions.CodeException("Error in code: " + error_message)
amuse.support.exceptions.CodeException: Error in code: no error message - code probably died, sorry.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data1/hochart/Orion_Asteroids/data/Fractal_N2500_Q0.5_R1.0pc_Qvir0.5/test.py", line 18, in <module>
    channel_a.copy()
    ~~~~~~~~~~~~~~^^
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/datamodel/particles.py", line 3723, in copy
    self.copy_all_attributes()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/datamodel/particles.py", line 3727, in copy_all_attributes
    self.copy_attributes(list(names_to_copy))
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/datamodel/particles.py", line 3644, in copy_attributes
    values = self.from_particles.get_values_in_store(self.from_indices, attributes)
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/datamodel/particles.py", line 1426, in get_values_in_store
    return self._private.attribute_storage.get_values_in_store(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        indices, attributes
        ^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/datamodel/incode_storage.py", line 1029, in get_values_in_store
    result = getter.get_attribute_values(self, attributes, indices_in_the_code)
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/datamodel/incode_storage.py", line 219, in get_attribute_values
    return_value = self.method(
        *indices, **storage.extra_keyword_arguments_for_getters_and_setters
    )
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/methods.py", line 168, in __call__
    result = self.method(*list_arguments, **keyword_arguments)
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/methods.py", line 166, in __call__
    object = self.precall()
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/methods.py", line 215, in precall
    return self.definition.precall(self)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/interface.py", line 373, in precall
    transition.do()
    ~~~~~~~~~~~~~^^
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/state.py", line 123, in do
    self.method.new_method()()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/methods.py", line 168, in __call__
    result = self.method(*list_arguments, **keyword_arguments)
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/methods.py", line 168, in __call__
    result = self.method(*list_arguments, **keyword_arguments)
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/methods.py", line 168, in __call__
    result = self.method(*list_arguments, **keyword_arguments)
  [Previous line repeated 1 more time]
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/support/methods.py", line 267, in __call__
    return self.method(*list_arguments, **keyword_arguments)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data1/hochart/Conda_Env/lib/python3.14/site-packages/amuse/rfi/core.py", line 138, in __call__
    raise exceptions.CodeException(
    ...<3 lines>...
    )
amuse.support.exceptions.CodeException: Exception when calling function 'commit_particles', of code 'ph4Interface', exception was 'Error in code: no error message - code probably died, sorry.'

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions