Python Simulations on x86 Machine - 2023.2 English

Vitis Tutorials: AI Engine

Document ID
XD100
Release Date
2023-11-29
Version
2023.2 English

Review the test.py file. Notice that it runs three unit tests: test_random_x1, test_random_x10, and test_random_x100. Each unit test creates two instances of the Particles class: particles_i and particles_j. Each Particles object contains arrays of floating point values for the particle positions, particle velocities, and mass (x y z vx vy vz m). These arrays are initalized with random values with the setSphereInitialConditions() function in pylib/particles.py file. The x and y positions are constrained to be in a sphere by invoking cos() and sin() functions. The remaining constrains are as follows:

  • minimum z initial position = -1000

  • maximum z initial position = 1000

  • minimum mass = 10

  • maximum mass = 110

  • minimum inital velocity = -2.0

  • maximum inital velocity = 2.0

  • timestep (ts) = 1

  • softening factor2 (sf2)= 1000

Each unit test then calls the pylib/nbody.py’s compute() function passing in the particles_i and particles_j objects as inputs. The nbody.compute() function is the vectorized python implementation of the N-Body Simulator and each call simulates 1 timestep. The nbody.compute() function outputs a new Particles object with the new x y z vx vy vz m floating point arrays.

Each unit test simulates a different number of particles for 1 timestep.

Test Name Number of Particles
test_random_x1 128
test_random_x10 1280
test_random_x100 12800

The 100 tile AI Engine design simulates 12,800 particles. The single tile AI Engine design (x1_design) simulates 128 particles, and the 10 tile AI Engine design (x10_design) simulates 1280 particles.