qarray_iter(3)
π qarray_iter β iterate through a distributed array π
okay so bestie, welcome to qarray_iter(3), part of the libqthread manual π
this one's all about yeeting your function across a distributed array and letting it run right next to the data, which is the whole vibe. no cap. π¦
β¨ 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 π
so these functions iterate efficiently over distributed arrays, and honestly? iconic. β¨
the most basic and naive one of the whole set is qarray_iter(). it applies the func function to every single element in the array, and it guarantees that the function will be executed near the specified data β like, it's literally right there, no long-distance situationship. π«Ά
the func function here is a basic qthread function, shaped like this:
void func (void *arg);
and the arg argument that gets handed to func is a pointer to an array element. periodt. π
π¦ the fancier ones π¦
okay so qarray_iter_loop(), qarray_iter_loop_nb(), qarray_iter_constloop(), and qarray_iter_loopaccum() are the more powerful iteration functions. they're largely identical to each other, with these little distinctions:
qarray_iter_constloop()forbids modifying the input qarray β hands off, no touching, it's giving look-don't-touch energy πqarray_iter_loopaccum()requires an accumulator function,acc, and it lets you calculate an accumulated value similar toqt_loopaccum_balance()π
both of those functions iterate over a range of values within the qarray, and that range is defined by the startat and stopat arguments.
the func argument is expected to be a function shaped like this:
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 */
}
}
so func gets handed a sub-range of the qarray to iterate over β not the whole thing, just its little slice, and it goes off and does its thing. π
the arg argument passed to the func function is the same argument as is passed to the qarray_iter_loop() argument. (yes, fr fr, that's the deal.)
and the qarray_iter_loop_nb() variant? that one lets the iterations happen in the background while the calling thread just... continues executing. main character energy, honestly. β¨
π SEE ALSO π
okay bestie that's the whole page, go iterate something gorgeous π
libqthread Β· APRIL 2011 β mwah, that's a wrap on qarray_iter(3), slay π
β¨
π¦ where this page comes from
- fedora 43: qthreads-devel 1.22^20251007gitcedb1fc-1.fc43 Β· BSD-3-Clause AND MIT AND dtoa
- fedora 44: qthreads-devel 1.22^20251007gitcedb1fc-2.fc44 Β· BSD-3-Clause AND MIT AND dtoa
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms