Exemplo n.º 1
0
    cmp_track_pb = CBuffer()
    cmp_particles = st.makeCopy(initial_particles, cbuffer=cmp_track_pb)

    cmp_output_buffer, elem_by_elem_offset, output_offset, min_turn_id = \
        st_OutputBuffer_create_output_cbuffer(eb, cmp_track_pb,
                                              until_turn_elem_by_elem=until_turn_elem_by_elem)

    elem_by_elem_config = st_ElemByElemConfig_create()
    assert elem_by_elem_config != st_NullElemByElemConfig

    start_elem_idx_arg = st_particle_index_t(0)
    until_turn_elem_by_elem_arg = st_particle_index_t(until_turn_elem_by_elem)

    ptr_belem_buffer = st_Buffer_new_mapped_on_cbuffer(eb)
    ptr_particles = st_Particles_cbuffer_get_particles(cmp_track_pb, 0)

    status = st_ElemByElemConfig_init(elem_by_elem_config, ptr_particles,
                                      ptr_belem_buffer, start_elem_idx_arg,
                                      until_turn_elem_by_elem_arg)
    assert status == 0

    assert cmp_output_buffer.n_objects == 3
    assert elem_by_elem_offset == 0
    assert output_offset == 1
    assert min_turn_id == 0

    status = st_ElemByElemConfig_assign_output_cbuffer(elem_by_elem_config,
                                                       cmp_output_buffer,
                                                       elem_by_elem_offset)
    line.LimitEllipse(a=0.5, b=0.35)
    line.BeamMonitor(num_stores=5,
                     start=10,
                     skip=5,
                     out_address=0,
                     max_particle_id=0,
                     min_particle_id=0,
                     is_rolling=True,
                     is_turn_ordered=False)

    NUM_PARTICLES = 100
    pb = st.ParticlesSet()
    pb.Particles(num_particles=100)

    ptr_pb = st_Buffer_new_mapped_on_cbuffer(pb.cbuffer)
    ptr_particles = st_Particles_cbuffer_get_particles(pb.cbuffer, 0)
    assert ptr_particles != st_NullParticles

    job = st.CudaTrackJob(line, pb)
    assert job.arch_str == 'cuda'
    assert job.requires_collecting
    assert job.has_output_buffer
    assert not job.has_elem_by_elem_output
    assert job.has_beam_monitor_output
    assert job.num_beam_monitors == 2

    # Copy the original contents of the line, the particle buffer and the out-
    # put buffer to a set of different buffers -> so we can keep track of them

    ptr_pb = st_Buffer_new_mapped_on_cbuffer(pb.cbuffer)
    assert ptr_pb != st_NullBuffer