Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
mona
Commits
e0bd79d7
Commit
e0bd79d7
authored
Nov 09, 2020
by
Matthieu Dorier
Browse files
added a pass of clang-format
parent
30ec7725
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
.clang-format
0 → 100644
View file @
e0bd79d7
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(margo)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentExternBlock: AfterExternBlock
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- MARGO_REGISTER
- MARGO_REGISTER_PROVIDER
- DEFINE_MARGO_RPC_HANDLER
- DECLARE_MARGO_RPC_HANDLER
- MERCURY_GEN_PROC
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- MERCURY_GEN_PROC
...
include/mona-coll.h
View file @
e0bd79d7
This diff is collapsed.
Click to expand it.
include/mona.h
View file @
e0bd79d7
This diff is collapsed.
Click to expand it.
src/mona-coll.c
View file @
e0bd79d7
This diff is collapsed.
Click to expand it.
src/mona-types.h
View file @
e0bd79d7
/*
* (C) 2020 The University of Chicago
*
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MONA_TYPES_H
...
...
@@ -19,31 +19,32 @@ typedef struct cached_msg* cached_msg_t;
typedef
struct
cached_msg
{
char
*
buffer
;
void
*
plugin_data
;
void
*
next
;
// may point to a cached_msg or to a pending_msg depending on context
void
*
next
;
// may point to a cached_msg or to a pending_msg depending on
// context
}
cached_msg
;
typedef
struct
pending_msg
*
pending_msg_t
;
typedef
struct
pending_msg
{
cached_msg_t
cached_msg
;
na_size_t
recv_size
;
na_addr_t
recv_addr
;
na_tag_t
recv_tag
;
cached_msg_t
cached_msg
;
na_size_t
recv_size
;
na_addr_t
recv_addr
;
na_tag_t
recv_tag
;
}
pending_msg
;
typedef
struct
mona_instance
{
// NA structures
na_class_t
*
na_class
;
na_context_t
*
na_context
;
na_class_t
*
na_class
;
na_context_t
*
na_context
;
// ABT structures
ABT_pool
progress_pool
;
ABT_xstream
progress_xstream
;
ABT_thread
progress_thread
;
ABT_pool
progress_pool
;
ABT_xstream
progress_xstream
;
ABT_thread
progress_thread
;
// ownership information
na_bool_t
owns_progress_pool
;
na_bool_t
owns_progress_xstream
;
na_bool_t
owns_na_class_and_context
;
na_bool_t
owns_progress_pool
;
na_bool_t
owns_progress_xstream
;
na_bool_t
owns_na_class_and_context
;
// finalization
na_bool_t
finalize_flag
;
na_bool_t
finalize_flag
;
// operation id cache
cached_op_id_t
op_id_cache
;
ABT_mutex
op_id_cache_mtx
;
...
...
@@ -51,14 +52,14 @@ typedef struct mona_instance {
mona_request_t
req_cache
;
ABT_mutex
req_cache_mtx
;
// message cache for high-level functions
cached_msg_t
msg_cache
;
ABT_mutex
msg_cache_mtx
;
cached_msg_t
msg_cache
;
ABT_mutex
msg_cache_mtx
;
// pending messages received in high-level mona_recv
pending_msg_t
pending_msg_oldest
;
// head of the queue
pending_msg_t
pending_msg_newest
;
// last of the queue
ABT_mutex
pending_msg_mtx
;
ABT_cond
pending_msg_cv
;
na_bool_t
pending_msg_queue_active
;
// a thread is queuing messages
pending_msg_t
pending_msg_oldest
;
// head of the queue
pending_msg_t
pending_msg_newest
;
// last of the queue
ABT_mutex
pending_msg_mtx
;
ABT_cond
pending_msg_cv
;
na_bool_t
pending_msg_queue_active
;
// a thread is queuing messages
}
mona_instance
;
typedef
struct
mona_request
{
...
...
@@ -70,9 +71,13 @@ typedef struct mona_request {
mona_request_t
next
;
// for the request cache
}
mona_request
;
#define MONA_REQUEST_INITIALIZER { ABT_EVENTUAL_NULL, NULL, NULL, NULL, NULL, NULL }
#define MONA_REQUEST_INITIALIZER \
{ \
ABT_EVENTUAL_NULL, NULL, NULL, NULL, NULL, NULL \
}
typedef
enum
hl_msg_type
{
typedef
enum
hl_msg_type
{
HL_MSG_SMALL
,
HL_MSG_LARGE
}
hl_msg_type
;
...
...
@@ -83,25 +88,26 @@ static inline cached_op_id_t get_op_id_from_cache(mona_instance_t mona)
{
cached_op_id_t
id
;
ABT_mutex_lock
(
mona
->
op_id_cache_mtx
);
if
(
mona
->
op_id_cache
)
{
id
=
mona
->
op_id_cache
;
if
(
mona
->
op_id_cache
)
{
id
=
mona
->
op_id_cache
;
mona
->
op_id_cache
=
id
->
next
;
id
->
next
=
NULL
;
id
->
next
=
NULL
;
}
else
{
na_op_id_t
*
op_id
=
NA_Op_create
(
mona
->
na_class
);
id
=
(
cached_op_id_t
)
calloc
(
1
,
sizeof
(
*
id
));
id
->
op_id
=
op_id
;
id
=
(
cached_op_id_t
)
calloc
(
1
,
sizeof
(
*
id
));
id
->
op_id
=
op_id
;
}
ABT_mutex_unlock
(
mona
->
op_id_cache_mtx
);
return
id
;
}
static
inline
void
return_op_id_to_cache
(
mona_instance_t
mona
,
cached_op_id_t
id
)
static
inline
void
return_op_id_to_cache
(
mona_instance_t
mona
,
cached_op_id_t
id
)
{
ABT_mutex_lock
(
mona
->
op_id_cache_mtx
);
cached_op_id_t
head
=
mona
->
op_id_cache
;
id
->
next
=
head
;
mona
->
op_id_cache
=
id
;
id
->
next
=
head
;
mona
->
op_id_cache
=
id
;
ABT_mutex_unlock
(
mona
->
op_id_cache_mtx
);
}
...
...
@@ -109,8 +115,8 @@ static inline void clear_op_id_cache(mona_instance_t mona)
{
ABT_mutex_lock
(
mona
->
op_id_cache_mtx
);
cached_op_id_t
cached_op
=
mona
->
op_id_cache
;
mona
->
op_id_cache
=
NULL
;
while
(
cached_op
)
{
mona
->
op_id_cache
=
NULL
;
while
(
cached_op
)
{
cached_op_id_t
tmp
=
cached_op
->
next
;
NA_Op_destroy
(
mona
->
na_class
,
cached_op
->
op_id
);
free
(
cached_op
);
...
...
@@ -125,10 +131,10 @@ static inline mona_request_t get_req_from_cache(mona_instance_t mona)
{
mona_request_t
req
;
ABT_mutex_lock
(
mona
->
req_cache_mtx
);
if
(
mona
->
req_cache
)
{
req
=
mona
->
req_cache
;
if
(
mona
->
req_cache
)
{
req
=
mona
->
req_cache
;
mona
->
req_cache
=
req
->
next
;
req
->
next
=
NULL
;
req
->
next
=
NULL
;
}
else
{
req
=
(
mona_request_t
)
calloc
(
1
,
sizeof
(
*
req
));
}
...
...
@@ -140,8 +146,8 @@ static inline void return_req_to_cache(mona_instance_t mona, mona_request_t req)
{
ABT_mutex_lock
(
mona
->
req_cache_mtx
);
mona_request_t
head
=
mona
->
req_cache
;
req
->
next
=
head
;
mona
->
req_cache
=
req
;
req
->
next
=
head
;
mona
->
req_cache
=
req
;
ABT_mutex_unlock
(
mona
->
req_cache_mtx
);
}
...
...
@@ -149,8 +155,8 @@ static inline void clear_req_cache(mona_instance_t mona)
{
ABT_mutex_lock
(
mona
->
req_cache_mtx
);
mona_request_t
cached_req
=
mona
->
req_cache
;
mona
->
req_cache
=
NULL
;
while
(
cached_req
)
{
mona
->
req_cache
=
NULL
;
while
(
cached_req
)
{
mona_request_t
tmp
=
cached_req
->
next
;
free
(
cached_req
);
cached_req
=
tmp
;
...
...
@@ -164,15 +170,14 @@ static inline cached_msg_t get_msg_from_cache(mona_instance_t mona)
{
cached_msg_t
msg
;
ABT_mutex_lock
(
mona
->
msg_cache_mtx
);
if
(
mona
->
msg_cache
)
{
msg
=
mona
->
msg_cache
;
if
(
mona
->
msg_cache
)
{
msg
=
mona
->
msg_cache
;
mona
->
msg_cache
=
msg
->
next
;
msg
->
next
=
NULL
;
msg
->
next
=
NULL
;
}
else
{
msg
=
(
cached_msg_t
)
calloc
(
1
,
sizeof
(
*
msg
));
msg
->
buffer
=
(
char
*
)
mona_msg_buf_alloc
(
mona
,
mona_msg_get_max_unexpected_size
(
mona
),
&
(
msg
->
plugin_data
));
msg
=
(
cached_msg_t
)
calloc
(
1
,
sizeof
(
*
msg
));
msg
->
buffer
=
(
char
*
)
mona_msg_buf_alloc
(
mona
,
mona_msg_get_max_unexpected_size
(
mona
),
&
(
msg
->
plugin_data
));
}
ABT_mutex_unlock
(
mona
->
msg_cache_mtx
);
return
msg
;
...
...
@@ -182,23 +187,23 @@ static inline void return_msg_to_cache(mona_instance_t mona, cached_msg_t msg)
{
ABT_mutex_lock
(
mona
->
msg_cache_mtx
);
cached_msg_t
head
=
mona
->
msg_cache
;
msg
->
next
=
head
;
mona
->
msg_cache
=
msg
;
msg
->
next
=
head
;
mona
->
msg_cache
=
msg
;
ABT_mutex_unlock
(
mona
->
msg_cache_mtx
);
}
static
inline
void
clear_msg_cache
(
mona_instance_t
mona
)
{
ABT_mutex_lock
(
mona
->
msg_cache_mtx
);
cached_msg_t
msg
=
mona
->
msg_cache
;
mona
->
msg_cache
=
NULL
;
while
(
msg
)
{
cached_msg_t
tmp
=
msg
->
next
;
mona_msg_buf_free
(
mona
,
msg
->
buffer
,
msg
->
plugin_data
);
free
(
msg
);
msg
=
tmp
;
}
ABT_mutex_unlock
(
mona
->
msg_cache_mtx
);
ABT_mutex_lock
(
mona
->
msg_cache_mtx
);
cached_msg_t
msg
=
mona
->
msg_cache
;
mona
->
msg_cache
=
NULL
;
while
(
msg
)
{
cached_msg_t
tmp
=
msg
->
next
;
mona_msg_buf_free
(
mona
,
msg
->
buffer
,
msg
->
plugin_data
);
free
(
msg
);
msg
=
tmp
;
}
ABT_mutex_unlock
(
mona
->
msg_cache_mtx
);
}
// Wait --------------------------------------------------------------
...
...
@@ -206,7 +211,7 @@ static inline void clear_msg_cache(mona_instance_t mona)
static
inline
na_return_t
mona_wait_internal
(
mona_request_t
req
)
{
na_return_t
*
waited_na_ret
=
NULL
;
na_return_t
na_ret
=
NA_SUCCESS
;
na_return_t
na_ret
=
NA_SUCCESS
;
ABT_eventual_wait
(
req
->
eventual
,
(
void
**
)
&
waited_na_ret
);
na_ret
=
*
waited_na_ret
;
...
...
src/mona.c
View file @
e0bd79d7
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment