Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
codes
codes
Commits
5a518276
Commit
5a518276
authored
Aug 04, 2015
by
Jonathan Jenkins
Browse files
map-ctx: add annotation getter, modify lpid mapper
parent
b113ac1d
Changes
4
Hide whitespace changes
Inline
Side-by-side
codes/codes-mapping-context.h
View file @
5a518276
...
...
@@ -83,11 +83,18 @@ struct codes_mctx codes_mctx_set_group_direct(
/* helper function to do a codes mapping - this function is subject to change
* based on what types of ctx exist
* NOTE: in GLOBAL_DIRECT mode, dest_lp_name and sender are ignored */
* NOTE: in GLOBAL_DIRECT mode, dest_lp_name and sender
_gid
are ignored */
tw_lpid
codes_mctx_to_lpid
(
struct
codes_mctx
const
*
ctx
,
char
const
*
dest_lp_name
,
tw_lp
const
*
sender
);
tw_lpid
sender_gid
);
/* helper function to extract which annotation a various map context maps to.
* annotation is allocated or NULL if unused */
char
const
*
codes_mctx_get_annotation
(
struct
codes_mctx
const
*
ctx
,
char
const
*
dest_lp_name
,
tw_lpid
sender_id
);
#endif
/* end of include guard: CODES_MAPPING_CONTEXT_H */
...
...
src/util/codes-mapping-context.c
View file @
5a518276
...
...
@@ -56,7 +56,7 @@ struct codes_mctx codes_mctx_set_group_direct(
tw_lpid
codes_mctx_to_lpid
(
struct
codes_mctx
const
*
ctx
,
char
const
*
dest_lp_name
,
tw_lp
const
*
sender
)
tw_lp
id
sender
_gid
)
{
struct
codes_mctx_annotation
const
*
anno
;
// short circuit for direct mappings
...
...
@@ -77,7 +77,7 @@ tw_lpid codes_mctx_to_lpid(
int
unused
,
rep_id
,
offset
;
// get sender info
codes_mapping_get_lp_info
(
sender
->
gid
,
sender_group
,
&
unused
,
NULL
,
&
unused
,
codes_mapping_get_lp_info
(
sender
_
gid
,
sender_group
,
&
unused
,
NULL
,
&
unused
,
NULL
,
&
rep_id
,
&
offset
);
int
dest_offset
;
...
...
@@ -88,7 +88,7 @@ tw_lpid codes_mctx_to_lpid(
tw_error
(
TW_LOC
,
"ERROR: Found no LPs of type %s in group %s "
"(source lpid %lu) with annotation: %s
\n
"
,
dest_lp_name
,
sender_group
,
sender
->
gid
,
dest_lp_name
,
sender_group
,
sender
_
gid
,
anno
->
ignore_annotations
?
"ignored"
:
(
anno
->
annotation
?
anno
->
annotation
:
"none"
));
...
...
@@ -106,6 +106,40 @@ tw_lpid codes_mctx_to_lpid(
return
rtn
;
}
char
const
*
codes_mctx_get_annotation
(
struct
codes_mctx
const
*
ctx
,
char
const
*
dest_lp_name
,
tw_lpid
sender_id
)
{
switch
(
ctx
->
type
)
{
case
CODES_MCTX_GLOBAL_DIRECT
:
return
codes_mapping_get_annotation_by_lpid
(
sender_id
);
case
CODES_MCTX_GROUP_MODULO
:
// if not ignoring the annotation, just return what's in the
// context
if
(
!
ctx
->
u
.
group_modulo
.
anno
.
ignore_annotations
)
return
ctx
->
u
.
group_modulo
.
anno
.
annotation
;
break
;
case
CODES_MCTX_GROUP_DIRECT
:
if
(
!
ctx
->
u
.
group_direct
.
anno
.
ignore_annotations
)
return
ctx
->
u
.
group_direct
.
anno
.
annotation
;
break
;
default:
tw_error
(
TW_LOC
,
"unrecognized or uninitialized context type: %d"
,
ctx
->
type
);
return
NULL
;
}
// at this point, we must be a group-wise mapping ignoring annotations
char
group
[
MAX_NAME_LENGTH
];
int
dummy
;
// only need the group name
codes_mapping_get_lp_info
(
sender_id
,
group
,
&
dummy
,
NULL
,
&
dummy
,
NULL
,
&
dummy
,
&
dummy
);
return
codes_mapping_get_annotation_by_name
(
group
,
dest_lp_name
);
}
/*
* Local variables:
* c-indent-level: 4
...
...
src/util/resource-lp.c
View file @
5a518276
...
...
@@ -467,7 +467,7 @@ static void resource_lp_issue_event_base(
SANITY_CHECK_CB
(
cb
,
resource_return
);
tw_lpid
resource_lpid
=
codes_mctx_to_lpid
(
map_ctx
,
RESOURCE_LP_NM
,
sender
);
codes_mctx_to_lpid
(
map_ctx
,
RESOURCE_LP_NM
,
sender
->
gid
);
tw_event
*
e
=
tw_event_new
(
resource_lpid
,
codes_local_latency
(
sender
),
sender
);
...
...
tests/map-ctx-test.c
View file @
5a518276
...
...
@@ -33,39 +33,68 @@ int main(int argc, char *argv[])
group_modulo_anno
=
codes_mctx_set_group_modulo
(
"baz"
,
false
);
group_direct_anno
=
codes_mctx_set_group_direct
(
1
,
"baz"
,
false
);
tw_lp
mock_lp
;
tw_lpid
rtn
;
tw_lpid
in
;
tw_lpid
rtn_id
;
char
const
*
rtn_anno
;
rtn
=
codes_mctx_to_lpid
(
&
direct
,
NULL
,
NULL
);
if
(
12ul
!=
rtn
)
ERR
(
"global_direct mapping: expected %lu, got %lu"
,
12ul
,
rtn
);
rtn_id
=
codes_mctx_to_lpid
(
&
direct
,
NULL
,
0
);
if
(
12ul
!=
rtn_id
)
ERR
(
"global_direct mapping: expected %lu, got %lu"
,
12ul
,
rtn_id
);
rtn_anno
=
codes_mctx_get_annotation
(
&
direct
,
NULL
,
0
);
if
(
rtn_anno
)
ERR
(
"global_direct mapping: expected NULL anno, got %s"
,
rtn_anno
);
mock_lp
.
gid
=
8ul
;
rtn
=
codes_mctx_to_lpid
(
&
group_modulo
,
"bar"
,
&
mock_lp
);
if
(
rtn
!=
9ul
)
ERR
(
"group_modulo mapping: expected %lu, got %lu"
,
9ul
,
rtn
);
in
=
8ul
;
rtn_id
=
codes_mctx_to_lpid
(
&
group_modulo
,
"bar"
,
in
);
if
(
rtn_id
!=
9ul
)
ERR
(
"group_modulo mapping: expected %lu, got %lu"
,
9ul
,
rtn_id
);
rtn_anno
=
codes_mctx_get_annotation
(
&
group_modulo
,
"bar"
,
in
);
if
(
rtn_anno
)
ERR
(
"group_modulo mapping: expected NULL anno, got %s"
,
rtn_anno
);
mock_lp
.
gid
=
12ul
;
rtn
=
codes_mctx_to_lpid
(
&
group_modulo
,
"bar"
,
&
mock_lp
);
if
(
rtn
!=
13ul
)
ERR
(
"group_modulo mapping: expected %lu, got %lu"
,
13ul
,
rtn
);
in
=
12ul
;
rtn_id
=
codes_mctx_to_lpid
(
&
group_modulo
,
"bar"
,
in
);
if
(
rtn_id
!=
13ul
)
ERR
(
"group_modulo mapping: expected %lu, got %lu"
,
13ul
,
rtn_id
);
rtn_anno
=
codes_mctx_get_annotation
(
&
group_modulo
,
"bar"
,
in
);
if
(
rtn_anno
)
ERR
(
"group_modulo mapping: expected NULL anno, got %s"
,
rtn_anno
);
rtn
=
codes_mctx_to_lpid
(
CODES_MCTX_DEFAULT
,
"bar"
,
&
mock_lp
);
if
(
rtn
!=
13ul
)
ERR
(
"group_modulo mapping (default): expected %lu, got %lu"
,
13ul
,
rtn
);
rtn_id
=
codes_mctx_to_lpid
(
CODES_MCTX_DEFAULT
,
"bar"
,
in
);
if
(
rtn_id
!=
13ul
)
ERR
(
"group_modulo mapping (default): expected %lu, got %lu"
,
13ul
,
rtn_id
);
rtn_anno
=
codes_mctx_get_annotation
(
CODES_MCTX_DEFAULT
,
"bar"
,
in
);
if
(
rtn_anno
)
ERR
(
"group_modulo mapping: expected NULL anno, got %s"
,
rtn_anno
);
rtn
=
codes_mctx_to_lpid
(
&
group_modulo_anno
,
"bar"
,
&
mock_lp
);
if
(
rtn
!=
15ul
)
ERR
(
"group_modulo annotated mapping: expected %lu, got %lu"
,
15ul
,
rtn
);
rtn_id
=
codes_mctx_to_lpid
(
&
group_modulo_anno
,
"bar"
,
in
);
if
(
rtn_id
!=
15ul
)
ERR
(
"group_modulo annotated mapping: expected %lu, got %lu"
,
15ul
,
rtn_id
);
rtn_anno
=
codes_mctx_get_annotation
(
&
group_modulo_anno
,
"bar"
,
in
);
if
(
strcmp
(
rtn_anno
,
"baz"
)
!=
0
)
ERR
(
"group_modulo mapping: expected anno
\"
baz
\"
, got %s"
,
rtn_anno
);
mock_lp
.
gid
=
10ul
;
rtn
=
codes_mctx_to_lpid
(
&
group_direct
,
"bar"
,
&
mock_lp
);
if
(
rtn
!=
14ul
)
ERR
(
"group_direct mapping (default): expected %lu, got %lu"
,
14ul
,
rtn
);
in
=
10ul
;
rtn_id
=
codes_mctx_to_lpid
(
&
group_direct
,
"bar"
,
in
);
if
(
rtn_id
!=
14ul
)
ERR
(
"group_direct mapping (default): expected %lu, got %lu"
,
14ul
,
rtn_id
);
rtn_anno
=
codes_mctx_get_annotation
(
&
group_direct
,
"bar"
,
in
);
if
(
rtn_anno
)
ERR
(
"group_modulo mapping: expected NULL anno, got %s"
,
rtn_anno
);
rtn
=
codes_mctx_to_lpid
(
&
group_direct_anno
,
"bar"
,
&
mock_lp
);
if
(
rtn
!=
16ul
)
ERR
(
"group_direct mapping (default): expected %lu, got %lu"
,
16ul
,
rtn
);
rtn_id
=
codes_mctx_to_lpid
(
&
group_direct_anno
,
"bar"
,
in
);
if
(
rtn_id
!=
16ul
)
ERR
(
"group_direct mapping (default): expected %lu, got %lu"
,
16ul
,
rtn_id
);
rtn_anno
=
codes_mctx_get_annotation
(
&
group_direct_anno
,
"bar"
,
in
);
if
(
strcmp
(
rtn_anno
,
"baz"
)
!=
0
)
ERR
(
"group_modulo mapping: expected anno
\"
baz
\"
, got %s"
,
rtn_anno
);
return
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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