Table of Contents

Name

qarray_iter - iterate through a distributed array

Synopsis

#include <qthread/qarray.h>

void
qarray_iter (qarray *a, const size_t startat, const size_t stopat, qthread_f func);

void
qarray_iter_loop (qarray *a, const size_t startat, const size_t stopat, qa_loop_f func, void *arg);

void
qarray_iter_loop_nb (qarray *a, const size_t startat, const size_t stopat, qa_loop_f func, void *arg, aligned_t *arg);

void
qarray_iter_constloop (qarray *a, const size_t startat, const size_t stopat, qa_loop_f func, void *arg);

void
qarray_iter_loopaccum (qarray *a, const size_t startat, const size_t stopat, qa_loopr_f func, void *arg, void *ret, const size_t retsize, qt_accum_f acc);

Description

These functions iterate efficiently over the distributed arrays. The most basic and naive of the set is qarray_iter(), which applies the func function to each element in the array, guaranteeing that the function will be executed near the specified data. The func function is a basic qthread function, of the following form:

void func (void *arg);

The arg argument to the func function is a pointer to an array element.

The qarray_iter_loop(),qarray_iter_loop_nb(),qarray_iter_constloop(), and qarray_iter_loopaccum() functions are more powerful iteration functions. They are largely identical, with the following distinctions: the qarray_iter_constloop() function forbids modifying the input qarray, and the qarray_iter_loopaccum() function requires an accumulator function, acc, and allows the calculation of an accumulated value similar to qt_loopaccum_balance(). Both functions iterate over a range of values within the qarray, which is defined by the startat and stopat arguments. The func argument is expected to be a function of the following form:

void func (const size_t startat, const size_t stopat, qarray *array, void *arg)
{

size_t i;
for (i = startat; i < stopat; i ++) {
/* do work */
}
}

The function func is given a sub-range of the qarray to iterate over. The arg argument passed to the func function is the same argument as is passed to the qarray_iter_loop() argument. The qarray_iter_loop_nb() variant allows the iterations to occur in the background while allowing the calling thread to continue execution.

See Also

qarray_create(3) , qarray_destroy(3) , qarray_shepof(3) , qarray_elem(3)


Table of Contents