CK_PR_FENCE_LOAD(3)

πŸ’– ck_pr_fence_load(3) β€” the manual page bestie πŸ’–

okay so you're here for ck_pr_fence_load(3), which lives in the Concurrency Kit and is giving "make my loads behave" energy. no cap.


✨ NAME ✨

ck_pr_fence_load β€” enforce partial ordering of load operations. yes queen, it's a fence, but for loads specifically. πŸ¦‹


🌸 LIBRARY 🌸

Concurrency Kit (libck, -lck). that's the one you link, mwah. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <ck_pr.h>

void
ck_pr_fence_load(void);

void
ck_pr_fence_strict_load(void);

two functions, both return nothing, both iconic in their own way. πŸ’–


πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea. ck_pr_fence_load() enforces the ordering of any memory load and ck_pr_load(3) operations relative to the moment you call it. translation: stuff you load after the fence doesn't get to jump in front of the fence. nope. line's closed. 🚧

also β€” any store operations that were committed on remote processors and received by the calling processor before the invocation of ck_pr_fence_load() get made visible only after a call to ck_pr_fence_load(). so the vibes stay in order, fr fr.

this function always serves as an implicit compiler barrier. periodt. the compiler cannot reorder across it, no discussion.

now for the architecture lore 🌈 β€” on architectures with CK_MD_TSO or CK_MD_PSO specified (total store ordering and partial store ordering respectively), this operation only serves as a compiler barrier and no fence instructions will be emitted. so if you were expecting an actual fence instruction, bestie, you're not getting one there. πŸ™ˆ

to force the unconditional emission of a load fence, use ck_pr_fence_strict_load(). that one does not play.

architectures implementing CK_MD_RMO always emit a load fence. no exceptions, main character energy. πŸ”₯


🧚 EXAMPLE 🧚

#include <ck_pr.h>

static unsigned int a;
static unsigned int b;

void
function(void)
{
        unsigned int snapshot_a, snapshot_b;

        snapshot_a = ck_pr_load_uint(&a);

        /*
         * Guarantee that the load from "a" completes
         * before the load from "b".
         */
        ck_pr_fence_load();
        snapshot_b = ck_pr_load_uint(&b);

        return;
}

see how the fence sits between the two loads? that's the whole plot. πŸ“


⭐ RETURN VALUES ⭐

This function has no return value. it just does the thing and leaves. zero notes. πŸ’€


πŸ’œ SEE ALSO πŸ’œ

Additional information available at http://concurrencykit.org/ 🌐


okay that's the whole page, go forth and fence responsibly bestie 🫢

and that's a wrap!! this one was dated April 7, 2013 and it's the ck_pr_fence_load(3) page, mwah, slay, bye πŸ’…βœ¨

πŸ“¦ where this page comes from