Snitch Runtime
Loading...
Searching...
No Matches
sync_decls.h
1// Copyright 2023 ETH Zurich and University of Bologna.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#pragma once
6
7#include <stdint.h>
8
9typedef struct {
10 uint32_t volatile cnt;
11 uint32_t volatile iteration;
13
14typedef struct {
15 volatile uint32_t *barrier_ptr;
16 uint32_t size;
17 uint32_t mask;
18 uint32_t base;
19 uint32_t is_participant;
21
23
24typedef enum {
25 SNRT_COLLECTIVE_UNICAST = 0,
26 SNRT_COLLECTIVE_MULTICAST = 1,
27 SNRT_REDUCTION_BARRIER = 2,
28 SNRT_REDUCTION_FADD = 3,
29 SNRT_REDUCTION_FMUL = 4,
30 SNRT_REDUCTION_FMIN = 5,
31 SNRT_REDUCTION_FMAX = 6,
32 SNRT_REDUCTION_ADD = 7,
33 SNRT_REDUCTION_MUL = 8,
34 SNRT_REDUCTION_MIN = 9,
35 SNRT_REDUCTION_MINU = 10,
36 SNRT_REDUCTION_MAX = 11,
37 SNRT_REDUCTION_MAXU = 12
38} snrt_collective_opcode_t;
39
40typedef union {
41 struct __attribute__((__packed__)) {
42 snrt_collective_opcode_t opcode : SNRT_COLLECTIVE_OPCODE_WIDTH;
43 uint64_t mask : (64 - SNRT_COLLECTIVE_OPCODE_WIDTH);
44 } f;
45 uint64_t w;
47
48extern volatile uint32_t _snrt_mutex;
49extern volatile snrt_barrier_t _snrt_barrier;
50extern volatile uint32_t _reduction_result;
51
52inline volatile uint32_t *snrt_mutex();
53
54inline void snrt_mutex_acquire(volatile uint32_t *pmtx);
55
56inline void snrt_mutex_ttas_acquire(volatile uint32_t *pmtx);
57
58inline void snrt_mutex_release(volatile uint32_t *pmtx);
59
60inline void snrt_cluster_hw_barrier();
61
62inline void snrt_global_sw_barrier(snrt_comm_t comm = NULL);
63
64inline void snrt_global_barrier(snrt_comm_t comm = NULL);
65
66inline uint32_t snrt_global_all_to_all_reduction(uint32_t value);
67
68inline void snrt_wait_writeback(uint32_t val);
69
70inline uint64_t snrt_get_collective_mask(snrt_comm_t comm);
71
72inline void snrt_enable_multicast(uint64_t mask);
73
74inline void snrt_disable_multicast();
75
76inline void snrt_enable_reduction(uint64_t mask,
77 snrt_collective_opcode_t reduction);
78
79inline void snrt_disable_reduction();
Definition sync_decls.h:9
Definition sync_decls.h:14
Definition sync_decls.h:40