until_turn_elem_by_elem) assert status == 0 status = st_Track_all_particles_element_by_element_until_turn( ptr_particles, elem_by_elem_config, ptr_belem_buffer, until_turn_elem_by_elem_arg) assert status == 0 status = st_Track_all_particles_until_turn(ptr_particles, ptr_belem_buffer, st_particle_index_t(until_turn)) assert status == 0 st_Buffer_delete(ptr_belem_buffer) st_ElemByElemConfig_delete(elem_by_elem_config) ptr_belem_buffer = st_NullBuffer elem_by_elem_config = st_NullElemByElemConfig print("cmp_output_buffer tracking finished") # ------------------------------------------------------------------------- track_pb = CBuffer() track_particles = st.makeCopy(initial_particles, cbuffer=track_pb) arch = "opencl" device = "2.0" job = st.TrackJob(eb, track_pb, until_turn_elem_by_elem, arch, device)
job.collect_output() for ii in range(0, job.num_beam_monitors): ptr_be_mon_output = st_Particles_cbuffer_get_particles( job.output.cbuffer, ii) ptr_init_be_mon_output = st_Particles_buffer_get_particles( init_output, ct.c_uint64(ii)) ptr_saved_be_mon_output = st_Particles_buffer_get_particles( saved_output, ct.c_uint64(ii)) assert st_Particles_compare_values(ptr_init_be_mon_output, ptr_be_mon_output) != 0 assert st_Particles_compare_values(ptr_saved_be_mon_output, ptr_be_mon_output) == 0 # Cleanup st_Buffer_delete(ptr_pb) st_Buffer_delete(ptr_line) st_Buffer_delete(ptr_output) st_Buffer_delete(init_pb) st_Buffer_delete(init_line) st_Buffer_delete(init_output) st_Buffer_delete(saved_pb) st_Buffer_delete(saved_line) st_Buffer_delete(saved_output) # end: /python/opencl/test_track_job_collect_and_push_opencl.py
if __name__ == '__main__': if not pyst.supports('cuda'): raise SystemExit("cuda support required for this test") num_particles = ct.c_uint64(100) pbuffer = st.st_Buffer_new(ct.c_uint64(0)) assert pbuffer != st.st_NullBuffer particles = st.st_Particles_new(pbuffer, num_particles) assert particles != st.st_NullParticles ptr_context = st.st_CudaContext_create() assert ptr_context != st.st_NullCudaContext particles_arg = st.st_CudaArgument_new(ptr_context) assert particles_arg != st.st_NullCudaArgument success = st.st_CudaArgument_send_buffer(particles_arg, pbuffer) assert success == 0 success = st.st_CudaArgument_receive_buffer(particles_arg, pbuffer) assert success == 0 st.st_CudaArgument_delete(particles_arg) st.st_CudaContext_delete(ptr_context) st.st_Buffer_delete(pbuffer) particles = st.st_NullParticles sys.exit(0)
st.st_CudaArgument_get_arg_buffer(lattice_arg), line_middle, line_end, ct.c_bool(True), num_blocks, threads_per_block) success = st.st_CudaArgument_receive_buffer(particles_arg, pbuffer) assert success == 0 cmp_pb = CBuffer() cmp_particles = pyst.makeCopy(initial_particles, cbuffer=cmp_pb) cmp_pbuffer = st.st_Buffer_new_mapped_on_cbuffer(cmp_pb) assert cmp_pbuffer != st.st_NullBuffer st.st_Track_all_particles_until_turn( st.st_Particles_buffer_get_particles(cmp_pbuffer, 0), lattice, ct.c_int64(1)) assert pyst.compareParticlesDifference( track_pb.get_object(0, cls=pyst.Particles), cmp_pb.get_object(0, cls=pyst.Particles), abs_treshold=2e-14) == 0 st.st_CudaArgument_delete(particles_arg) st.st_CudaArgument_delete(lattice_arg) st.st_CudaContext_delete(ctx) st.st_Buffer_delete(pbuffer) st.st_Buffer_delete(lattice) st.st_Buffer_delete(cmp_pbuffer) sys.exit(0)
assert (ret == 0) print(elem_by_elem_offset.value) print(beam_monitor_offset.value) print(min_turn_id.value) assert (elem_by_elem_offset.value == 0) assert (beam_monitor_offset.value >= elem_by_elem_offset.value) assert (min_turn_id.value >= 0) assert (output_buffer.base == output_buffer_base_addr) assert (output_buffer.size == output_buffer_size) assert (saved_max_num_objects == output_buffer.max_objects) assert (saved_max_num_slots == output_buffer.max_slots) assert (saved_max_num_dataptrs == output_buffer.max_pointers) assert (saved_max_num_garbage == output_buffer.max_garbage) assert (st.st_Buffer_get_num_of_objects(mapped_output_buffer) == num_objects.value) # Cleanup st.st_Buffer_delete(pb) st.st_Buffer_delete(eb) st.st_Buffer_delete(mapped_output_buffer) pb = st.st_NullBuffer eb = st.st_NullBuffer mapped_output_buffer = st.st_NullBuffer sys.exit(0)