Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 5 additions & 34 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Language: Cpp
BasedOnStyle: LLVM
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
Expand Down Expand Up @@ -36,29 +36,7 @@ AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseArrows: false
AlignCaseColons: false
AlignConsecutiveTableGenBreakingDAGArgColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveTableGenCondOperatorColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveTableGenDefinitionColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Expand All @@ -68,7 +46,6 @@ AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseExpressionOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
Expand All @@ -77,7 +54,9 @@ AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
Expand Down Expand Up @@ -105,18 +84,15 @@ BraceWrapping:
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: false
BreakAfterReturnType: None
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakFunctionDefinitionParameters: false
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
BreakTemplateDeclarations: MultiLine
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
Expand Down Expand Up @@ -172,15 +148,12 @@ IntegerLiteralSeparator:
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: true
AtStartOfFile: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MainIncludeChar: Quote
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
Expand Down Expand Up @@ -249,7 +222,6 @@ SpacesInLineCommentPrefix:
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
ExceptDoubleParentheses: false
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Expand All @@ -261,7 +233,6 @@ StatementAttributeLikeMacros:
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TableGenBreakInsideDAGArg: DontBreak
TabWidth: 8
UseTab: Never
VerilogBreakBetweenInstancePorts: true
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/clang-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@ jobs:
sudo apt-get update
sudo apt-get install clang-format

- name: Run clang-format
- name: Verify clang-format installation
run: |
git diff --exit-code --ignore-submodules -- '*.cpp' '*.h' '*.c' '*.hpp'
if [ $? -ne 0 ]; then
echo "Clang-format failed. Please format your code."
clang-format --version

- name: Run clang-format on all files
run: |
# From anywhere inside the repo:
repo_root=$(git rev-parse --show-toplevel) && cd "$repo_root"
git ls-files -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' \
| xargs -0 -r clang-format -i

# Fail if formatting made changes
git diff --exit-code || {
echo "clang-format changed files above. Please commit the formatting."
exit 1
fi
}
71 changes: 40 additions & 31 deletions include/converse.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ int CmiMyRank();
int CmiNumPes();
int CmiNumNodes();
// FIXME
//#define CmiPhysicalNodeID(node) (node)
// #define CmiPhysicalNodeID(node) (node)
extern int CmiPhysicalNodeID(int pe);
int CmiNodeOf(int pe);
int CmiRankOf(int pe);
Expand Down Expand Up @@ -836,20 +836,20 @@ enum ncpyFreeNcpyOpInfoMode {
#define CMK_SPANTREE_MAXSPAN 4
#define CST_W (CMK_SPANTREE_MAXSPAN)
#define CST_NN (CmiNumNodes())
#define CmiNodeSpanTreeParent(n) ((n) ? (((n)-1) / CST_W) : (-1))
#define CmiNodeSpanTreeParent(n) ((n) ? (((n) - 1) / CST_W) : (-1))
#define CmiNodeSpanTreeChildren(n, c) \
do { \
int _i; \
for (_i = 0; _i < CST_W; _i++) { \
int _x = (n)*CST_W + _i + 1; \
int _x = (n) * CST_W + _i + 1; \
if (_x < CST_NN) \
(c)[_i] = _x; \
} \
} while (0)
#define CmiNumNodeSpanTreeChildren(n) \
((((n) + 1) * CST_W < CST_NN) \
? CST_W \
: ((((n)*CST_W + 1) >= CST_NN) ? 0 : ((CST_NN - 1) - (n)*CST_W)))
: ((((n) * CST_W + 1) >= CST_NN) ? 0 : ((CST_NN - 1) - (n) * CST_W)))
#define CST_R(p) (CmiRankOf(p))
#define CST_NF(n) (CmiNodeFirst(n))
#define CST_SP(n) (CmiNodeSpanTreeParent(n))
Expand Down Expand Up @@ -920,63 +920,72 @@ void registerTraceInit(void (*fn)(char **argv));

int CmiDeliverMsgs(int maxmsgs);

#define CmiMemoryReadFence() std::atomic_thread_fence(std::memory_order_seq_cst)
#define CmiMemoryWriteFence() std::atomic_thread_fence(std::memory_order_seq_cst)
#define CmiMemoryReadFence() std::atomic_thread_fence(std::memory_order_seq_cst)
#define CmiMemoryWriteFence() \
std::atomic_thread_fence(std::memory_order_seq_cst)

extern CmiNodeLock CmiMemLock_lock;
#define CmiMemLock() do{if (CmiMemLock_lock) CmiLock(CmiMemLock_lock);} while (0)
#define CmiMemLock() \
do { \
if (CmiMemLock_lock) \
CmiLock(CmiMemLock_lock); \
} while (0)

#define CmiMemUnlock() do{if (CmiMemLock_lock) CmiUnlock(CmiMemLock_lock);} while (0)
#define CmiMemUnlock() \
do { \
if (CmiMemLock_lock) \
CmiUnlock(CmiMemLock_lock); \
} while (0)

template <typename T> struct CmiIsAtomic : std::false_type {};
template <typename T> struct CmiIsAtomic<std::atomic<T>> : std::true_type {};

template <typename T>
typename std::enable_if<CmiIsAtomic<T>::value, typename T::value_type>::type
CmiAtomicFetchAndIncImpl(T& input) {
return std::atomic_fetch_add(&input, typename T::value_type(1));
CmiAtomicFetchAndIncImpl(T &input) {
return std::atomic_fetch_add(&input, typename T::value_type(1));
}

template <typename T>
typename std::enable_if<!CmiIsAtomic<T>::value, T>::type
CmiAtomicFetchAndIncImpl(T& input) {
T old = input;
++input;
return old;
CmiAtomicFetchAndIncImpl(T &input) {
T old = input;
++input;
return old;
}

#define CmiMemoryAtomicFetchAndInc(input, output) ((output) = CmiAtomicFetchAndIncImpl(input))
#define CmiMemoryAtomicFetchAndInc(input, output) \
((output) = CmiAtomicFetchAndIncImpl(input))

#define CmiEnableUrgentSend(yn) /* intentionally left empty */

typedef struct CmmTableStruct *CmmTable;

#define CmmWildCard (-1)

//typedef void (*CmmPupMessageFn)(pup_er p,void **msg);
//CmmTable CmmPup(pup_er p, CmmTable t, CmmPupMessageFn msgpup);

CmmTable CmmNew(void);
void CmmFree(CmmTable t);
void CmmFreeAll(CmmTable t);
void CmmPut(CmmTable t, int ntags, int *tags, void *msg);
void *CmmFind(CmmTable t, int ntags, int *tags, int *returntags, int del);
int CmmEntries(CmmTable t);
int CmmGetLastTag(CmmTable t, int ntags, int *tags);
#define CmmGet(t,nt,tg,rt) (CmmFind((t),(nt),(tg),(rt),1))
#define CmmProbe(t,nt,tg,rt) (CmmFind((t),(nt),(tg),(rt),0))
// typedef void (*CmmPupMessageFn)(pup_er p,void **msg);
// CmmTable CmmPup(pup_er p, CmmTable t, CmmPupMessageFn msgpup);

CmmTable CmmNew(void);
void CmmFree(CmmTable t);
void CmmFreeAll(CmmTable t);
void CmmPut(CmmTable t, int ntags, int *tags, void *msg);
void *CmmFind(CmmTable t, int ntags, int *tags, int *returntags, int del);
int CmmEntries(CmmTable t);
int CmmGetLastTag(CmmTable t, int ntags, int *tags);
#define CmmGet(t, nt, tg, rt) (CmmFind((t), (nt), (tg), (rt), 1))
#define CmmProbe(t, nt, tg, rt) (CmmFind((t), (nt), (tg), (rt), 0))

#ifndef CMI_CACHE_LINE_SIZE
#ifdef __cpp_lib_hardware_interference_size
# define CMI_CACHE_LINE_SIZE std::hardware_destructive_interference_size
#define CMI_CACHE_LINE_SIZE std::hardware_destructive_interference_size
#elif CMK_PPC64 || (defined __APPLE__ && defined __arm64__)
# define CMI_CACHE_LINE_SIZE 128
#define CMI_CACHE_LINE_SIZE 128
#else
# define CMI_CACHE_LINE_SIZE 64
#define CMI_CACHE_LINE_SIZE 64
#endif
#endif
//partitions
// partitions

typedef enum Partition_Type {
PARTITION_SINGLETON,
Expand Down
24 changes: 11 additions & 13 deletions src/barrier.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
// Acknowledgement: adopted from https://github.com/uiuc-hpc/lci/blob/master/lct/tbarrier/tbarrier.cpp
// Acknowledgement: adopted from
// https://github.com/uiuc-hpc/lci/blob/master/lct/tbarrier/tbarrier.cpp

#include <iostream>
#include <atomic>
#include <iostream>
#include <thread>

class Barrier {
private:
private:
alignas(64) std::atomic<int> waiting;
alignas(64) std::atomic<int64_t> step;
alignas(64) int thread_num_;

public:
public:
explicit Barrier(int thread_num)
: waiting(0), step(0), thread_num_(thread_num)
{}
: waiting(0), step(0), thread_num_(thread_num) {}

int64_t arrive()
{
int64_t arrive() {
int64_t mstep = step.load();
if (++waiting == thread_num_) {
waiting = 0;
Expand All @@ -27,13 +26,12 @@ class Barrier {

bool test_ticket(int64_t ticket) { return ticket != step; }

void wait_ticket(int64_t ticket)
{
while (!test_ticket(ticket)) continue;
void wait_ticket(int64_t ticket) {
while (!test_ticket(ticket))
continue;
}

void wait()
{
void wait() {
int64_t ticket = arrive();
wait_ticket(ticket);
}
Expand Down
8 changes: 4 additions & 4 deletions src/cldb.none.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ void CldHandler(char *msg) {
msg); // use priority queue when we add priority queue
}

void CldEnqueueGroup(CmiGroup grp, void *msg, int infofn)
{
int len, queueing, priobits; unsigned int *prioptr;
void CldEnqueueGroup(CmiGroup grp, void *msg, int infofn) {
int len, queueing, priobits;
unsigned int *prioptr;
CldInfoFn ifn = (CldInfoFn)CmiHandlerToFunction(infofn);
CldPackFn pfn;
ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
Expand All @@ -36,7 +36,7 @@ void CldEnqueueGroup(CmiGroup grp, void *msg, int infofn)
ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
}
CldSwitchHandler((char *)msg, CldHandlerIndex);
CmiSetInfo(msg,infofn);
CmiSetInfo(msg, infofn);

CmiSyncMulticastAndFree(grp, len, msg);
}
Expand Down
5 changes: 2 additions & 3 deletions src/cldb.rand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ void CldEnqueue(int pe, void *msg, int infofn) {
/* CsdEnqueueGeneral is not thread or SIGIO safe */
// CmiPrintf(" myself processor %d ==> %d, length=%d Timer:%f , priori=%d
// \n", CmiMyPe(), pe, len, CmiWallTimer(), *prioptr);
//CsdEnqueueGeneral(msg, queueing, priobits, prioptr);
CmiPushPE(CmiMyPe(), len,
msg);
// CsdEnqueueGeneral(msg, queueing, priobits, prioptr);
CmiPushPE(CmiMyPe(), len, msg);
} else {
ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
if (pfn && CmiNodeOf(pe) != CmiMyNode()) {
Expand Down
Loading