qarray_create(3)
π qarray_create β allocate a runtime distributed array π
okay bestie, welcome to qarray_create(3) from libqthread πΈ this one's a lil trio of functions that spin up distributed array objects for you. stay with me, it's giving main character energy fr fr.
β¨ NAME β¨
qarray_create β allocate a runtime distributed array π«Ά
π SYNOPSIS π
#include <qthread/qarray.h>
qarray *
qarray_create (const size_t count, const size_t unit_size);
qarray *
qarray_create_tight (const size_t count, const size_t unit_size);
qarray *
qarray_create_configured (const size_t count, const size_t unit_size,
const distribution_t d, const char tight,
const int seg_pages);
π DESCRIPTION π
so these three functions all initialize qarray distributed array objects. no cap. all three of them create an array that holds at least count elements, and each element is at least unit_size bytes long. π
now here's the tea on the differences:
qarray_create()may round that element size up to the next-largest multiple of eight.qarray_create_tight()is guaranteed NOT to do that, so the elements end up packed tightly in the array. slay.qarray_create_configured()gives you way more control over how the array is actually implemented β you get to specify the distribution pattern (d) and the length of the distributed array segments (seg_pages).
about that seg_pages argument, bestie: it's the number of memory pages in a single segment. memory literally cannot be distributed in units smaller than a single page, so that's the floor. and if seg_pages is zero, a default value gets chosen for you. β¨
the possible values for d are, in order:
FIXED_HASHβ distributes the memory across the available shepherds evenly, using a basic round-robin assignment mechanism based on the address of the initial page of each segment. Array segments cannot be relocated.FIXED_FIELDSβ distributes the memory evenly across all shepherds, keeping long contiguous sets of segments on each shepherd. Segment locations are defined by a simple math operation on the index, so array segments cannot be relocated.ALL_LOCALβ assigns the entire array to the local shepherd. Array segments cannot be relocated.ALL_RANDβ assigns the entire array to a random shepherd. Array segments cannot be relocated.ALL_LEASTβ assigns the entire array to the shepherd with the least qarray segments currently assigned to it. Array segments cannot be relocated.DIST_STRIPESβ assigns array segments with a round-robin mechanism. Segment location is stored in the segment, so segments can be relocated, but finding a segment requires extra memory operations. πDIST_FIELDSβ assigns array segments evenly across all shepherds, attempting to maintain long contiguous sets of segments on each shepherd. Segment location is stored in the segment, so segments can be relocated, but finding a segment requires extra memory operations. πDIST_RANDβ assigns array segments randomly to shepherds. Segment location is stored in the segment, so segments can be relocated, but finding a segment requires extra memory operations. πDIST_LEASTβ assigns each array segment to whichever shepherd has the fewest array segments assigned to it at creation time. Segment location is stored in the segment, so segments can be relocated, but finding a segment requires extra memory operations. π
ngl the pattern is kinda iconic: theFIXED_*andALL_*ones lock your segments in place, and theDIST_*ones let segments move around but charge you extra memory ops to find them. iykyk π
π SEE ALSO π
qarray_destroy(3), qarray_iter(3), qarray_shepof(3), qarray_elem(3)
and that's the whole vibe check, bestie π this page comes from libqthread, dated MAY 2009 β a whole era, honestly. go forth and distribute ur arrays. π¦β¨
π¦ 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