Exemple #1
0
    def step(self, dt):
        """ Perform stepping for the integrating calcs """

        cl_dt = get_real(dt, self.cl_precision)

        # get the current stage of the integration
        k_num = self.cstep

        for array in self.arrays:

            # get the number of particles
            np = array.get_number_of_particles()

            # get the command queue for the array
            queue = array.queue
            
            # get the mapping for this array and this stage
            to_step = self.step_props[ array.name ][k_num]

            for prop in to_step:

                initial_prop = to_step[ prop ][0]
                step_prop = to_step[ prop ][1]

                prop_buffer = array.get_cl_buffer( prop )
                step_buffer = array.get_cl_buffer( step_prop )
                initial_buffer = array.get_cl_buffer( initial_prop )

                self.program.step_array(queue, (np,1,1), (1,1,1),
                                        initial_buffer, step_buffer,
                                        prop_buffer, cl_dt)
        self.cstep += 1
Exemple #2
0
    def final_step(self, calc, dt):
        """ Perform the final step for the integrating calc """
        updates = calc.updates
        nupdates = calc.nupdates
        queue = calc.queue

        pa = self.arrays[calc.dnum]
        np = pa.get_number_of_particles()

        cl_dt = get_real(dt, self.cl_precision)

        for i in range(nupdates):
            initial_prop = self.initial_props[calc.id][i]
            k_prop = self.k_props[calc.id]['k1'][i]
            update_prop = updates[i]

            initial_buffer = pa.get_cl_buffer(initial_prop)
            update_buffer = pa.get_cl_buffer(update_prop)
            k1_buffer = pa.get_cl_buffer(k_prop)
            tmp_buffer = pa.get_cl_buffer('tmpx')
           
            self.program.step_array(queue, (np,1,1), (1,1,1),
                                    initial_buffer, k1_buffer,
                                    tmp_buffer, cl_dt).wait()

            cl.enqueue_copy(queue, src=tmp_buffer,
                            dest=initial_buffer,
                            ).wait()

            cl.enqueue_copy(queue, src=tmp_buffer,
                            dest=update_buffer,
                            ).wait()
Exemple #3
0
    def step(self, calcs, dt):
        """ Perform stepping for the integrating calcs """

        ncalcs = len(calcs)

        cl_dt = get_real(dt, self.cl_precision)

        k_num = 'k' + str(self.cstep)
        for i in range(ncalcs):
            calc = calcs[i]
            queue = calc.queue

            if calc.integrates:
                
                updates = calc.updates
                nupdates = calc.nupdates

                # get the destination particle array for this calc
            
                pa = self.arrays[calc.dnum]
                np = pa.get_number_of_particles()

                for j in range(nupdates):
                    update_prop = updates[j]
                    k_prop = self.k_props[calc.id][k_num][j]

                    current_buffer = pa.get_cl_buffer(update_prop)
                    step_buffer = pa.get_cl_buffer(k_prop)
                    tmp_buffer = pa.get_cl_buffer('tmpx')
                
                    self.program.step_array(queue, (np,1,1), (1,1,1),
                                            current_buffer, step_buffer,
                                            tmp_buffer, cl_dt)

                    cl.enqueue_copy(queue, src=tmp_buffer,
                                    dest=current_buffer)
                    
                pass
            pass

        # Increment the step by 1

        self.cstep += 1
Exemple #4
0
    def step(self, calcs, dt):
        """ Perform stepping for the integrating calcs """

        ncalcs = len(calcs)

        cl_dt = get_real(dt, self.cl_precision)

        k_num = 'k' + str(self.cstep)
        for i in range(ncalcs):
            calc = calcs[i]
            queue = calc.queue

            if calc.integrates:

                updates = calc.updates
                nupdates = calc.nupdates

                # get the destination particle array for this calc

                pa = self.arrays[calc.dnum]
                np = pa.get_number_of_particles()

                for j in range(nupdates):
                    update_prop = updates[j]
                    k_prop = self.k_props[calc.id][k_num][j]

                    current_buffer = pa.get_cl_buffer(update_prop)
                    step_buffer = pa.get_cl_buffer(k_prop)
                    tmp_buffer = pa.get_cl_buffer('tmpx')

                    self.program.step_array(queue, (np, 1, 1), (1, 1, 1),
                                            current_buffer, step_buffer,
                                            tmp_buffer, cl_dt)

                    cl.enqueue_copy(queue, src=tmp_buffer, dest=current_buffer)

                pass
            pass

        # Increment the step by 1

        self.cstep += 1
Exemple #5
0
    def final_step(self, calc, dt):
        """ Perform the final step for the integrating calc """
        updates = calc.updates
        nupdates = calc.nupdates
        queue = calc.queue

        pa = self.arrays[calc.dnum]
        np = pa.get_number_of_particles()

        cl_dt = get_real(dt, self.cl_precision)

        for i in range(nupdates):
            initial_prop = self.initial_props[calc.id][i]
            k_prop = self.k_props[calc.id]['k1'][i]
            update_prop = updates[i]

            initial_buffer = pa.get_cl_buffer(initial_prop)
            update_buffer = pa.get_cl_buffer(update_prop)
            k1_buffer = pa.get_cl_buffer(k_prop)
            tmp_buffer = pa.get_cl_buffer('tmpx')

            self.program.step_array(queue, (np, 1, 1), (1, 1, 1),
                                    initial_buffer, k1_buffer, tmp_buffer,
                                    cl_dt).wait()

            cl.enqueue_copy(
                queue,
                src=tmp_buffer,
                dest=initial_buffer,
            ).wait()

            cl.enqueue_copy(
                queue,
                src=tmp_buffer,
                dest=update_buffer,
            ).wait()