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
3e632f0b
Commit
3e632f0b
authored
Jun 29, 2015
by
Jonathan Jenkins
Browse files
jobmap interface change, fixes
parent
ec142cc9
Changes
6
Hide whitespace changes
Inline
Side-by-side
codes/codes-jobmap.h
View file @
3e632f0b
...
...
@@ -11,9 +11,9 @@
*
* Example:
*
* job 0 1 2
* rank 0 1 2 0 1 0 1 2 3
* ID 0 1 2 3 4 5 6 7 8 (<-- LP relative ID)
* job 0 1 2
(<-- jobmap defined "local" IDs)
* rank 0 1 2 0 1 0 1 2 3
(<-- jobmap defined "local" IDs)
* ID 0 1 2 3 4 5 6 7 8 (<-- LP relative
"global"
ID)
* LP A B C D E F G H I (<-- provided by codes-mapping)
* */
...
...
@@ -46,10 +46,20 @@ codes_jobmap_configure(enum codes_jobmap_type t, void const * params);
void
codes_jobmap_destroy
(
struct
codes_jobmap_ctx
*
c
);
struct
codes_jobmap_id
codes_jobmap_lookup
(
/* main mapping functions - bidirectional mapping is needed:
* - global -> local ID for initialization
* - local -> global ID for communication between local IDs
*
* functions return {-1, -1} and -1, respectively, for invalid id input */
struct
codes_jobmap_id
codes_jobmap_to_local_id
(
int
id
,
struct
codes_jobmap_ctx
const
*
c
);
int
codes_jobmap_to_global_id
(
struct
codes_jobmap_id
id
,
struct
codes_jobmap_ctx
const
*
c
);
int
codes_jobmap_get_num_jobs
(
struct
codes_jobmap_ctx
const
*
c
);
#endif
...
...
src/util/codes-jobmap-method-impl.h
View file @
3e632f0b
...
...
@@ -13,10 +13,11 @@
struct
codes_jobmap_impl
{
/* returns nonzero on failure (to distinguish between no-state (dummy) and
* failure) */
int
(
*
configure
)(
void
const
*
params
,
void
**
ctx
);
void
(
*
destroy
)(
void
*
ctx
);
struct
codes_jobmap_id
(
*
lookup
)
(
int
id
,
void
const
*
ctx
);
int
(
*
get_num_jobs
)(
void
const
*
ctx
);
int
(
*
configure
)(
void
const
*
params
,
void
**
ctx
);
void
(
*
destroy
)(
void
*
ctx
);
struct
codes_jobmap_id
(
*
to_local
)
(
int
id
,
void
const
*
ctx
);
int
(
*
to_global
)
(
struct
codes_jobmap_id
id
,
void
const
*
ctx
);
int
(
*
get_num_jobs
)(
void
const
*
ctx
);
};
struct
codes_jobmap_ctx
{
...
...
src/util/codes-jobmap.c
View file @
3e632f0b
...
...
@@ -45,11 +45,18 @@ void codes_jobmap_destroy(struct codes_jobmap_ctx *c)
free
(
c
);
}
struct
codes_jobmap_id
codes_jobmap_
lookup
(
struct
codes_jobmap_id
codes_jobmap_
to_local_id
(
int
id
,
struct
codes_jobmap_ctx
const
*
c
)
{
return
c
->
impl
->
lookup
(
id
,
c
->
ctx
);
return
c
->
impl
->
to_local
(
id
,
c
->
ctx
);
}
int
codes_jobmap_to_global_id
(
struct
codes_jobmap_id
id
,
struct
codes_jobmap_ctx
const
*
c
)
{
return
c
->
impl
->
to_global
(
id
,
c
->
ctx
);
}
int
codes_jobmap_get_num_jobs
(
struct
codes_jobmap_ctx
const
*
c
)
...
...
src/util/jobmap-impl/jobmap-dummy.c
View file @
3e632f0b
...
...
@@ -11,9 +11,9 @@
static
int
jobmap_dummy_configure
(
void
const
*
params
,
void
**
ctx
)
{
int
*
num_jobs
=
*
ctx
;
num_jobs
=
malloc
(
sizeof
(
*
num_jobs
));
int
*
num_jobs
=
malloc
(
sizeof
(
*
num_jobs
));
assert
(
num_jobs
);
*
ctx
=
num_jobs
;
struct
codes_jobmap_params_dummy
const
*
p
=
params
;
...
...
@@ -27,18 +27,34 @@ static void jobmap_dummy_destroy(void * ctx)
free
(
ctx
);
}
static
struct
codes_jobmap_id
jobmap_dummy_lookup
(
int
id
,
void
const
*
ctx
)
static
struct
codes_jobmap_id
jobmap_dummy_to_local
(
int
id
,
void
const
*
ctx
)
{
int
const
*
num_jobs
=
ctx
;
struct
codes_jobmap_id
rtn
=
{
-
1
,
-
1
}
;
struct
codes_jobmap_id
rtn
;
if
(
id
>=
*
num_jobs
)
{
if
(
id
<
*
num_jobs
)
{
rtn
.
job
=
id
;
rtn
.
rank
=
0
;
}
else
{
rtn
.
job
=
-
1
;
rtn
.
rank
=
-
1
;
}
return
rtn
;
}
static
int
jobmap_dummy_to_global
(
struct
codes_jobmap_id
id
,
void
const
*
ctx
)
{
int
const
*
num_jobs
=
ctx
;
if
(
id
.
job
<
*
num_jobs
)
return
id
.
job
;
else
return
-
1
;
}
int
jobmap_dummy_get_num_jobs
(
void
const
*
ctx
)
{
return
*
(
int
const
*
)
ctx
;
...
...
@@ -47,7 +63,8 @@ int jobmap_dummy_get_num_jobs(void const * ctx)
struct
codes_jobmap_impl
jobmap_dummy_impl
=
{
jobmap_dummy_configure
,
jobmap_dummy_destroy
,
jobmap_dummy_lookup
,
jobmap_dummy_to_local
,
jobmap_dummy_to_global
,
jobmap_dummy_get_num_jobs
};
...
...
tests/Makefile.subdir
View file @
3e632f0b
...
...
@@ -52,7 +52,7 @@ tests_rc_stack_test_SOURCES = tests/rc-stack-test.c
tests_jobmap_test_LDADD
=
$(testlib)
${ROSS_LIBS}
tests_jobmap_test_LDFLAGS
=
${ROSS_LDFLAGS}
tests_jobmap_test_SOURCES
=
tests/
rc-stack
-test.c
tests_jobmap_test_SOURCES
=
tests/
jobmap
-test.c
tests_workload_codes_workload_test_LDADD
=
$(testlib)
${ROSS_LIBS}
tests_workload_codes_workload_test_LDFLAGS
=
${ROSS_LDFLAGS}
...
...
tests/jobmap-test.c
View file @
3e632f0b
...
...
@@ -24,18 +24,22 @@ int main(int argc, char *argv[])
/* initialize */
c
=
codes_jobmap_configure
(
CODES_JOBMAP_DUMMY
,
&
p
);
if
(
c
)
ERR
(
"jobmap configure failure"
);
if
(
!
c
)
ERR
(
"jobmap configure failure"
);
/* successful lookups */
struct
codes_jobmap_id
id
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
id
=
codes_jobmap_
lookup
(
i
,
c
);
id
=
codes_jobmap_
to_local_id
(
i
,
c
);
if
(
id
.
job
!=
i
||
id
.
rank
!=
0
)
ERR
(
"lookup failure for %d: expected (%d,%d), got (%d,%d)"
,
i
,
i
,
0
,
id
.
job
,
id
.
rank
);
else
{
id
.
job
=
-
1
;
id
.
rank
=
-
1
;
}
}
/* bad lookup */
id
=
codes_jobmap_
lookup
(
10
,
c
);
id
=
codes_jobmap_
to_local_id
(
10
,
c
);
if
(
id
.
job
!=
-
1
||
id
.
rank
!=
-
1
)
ERR
(
"lookup expected failure for 10: expected (%d,%d), got (%d,%d)"
,
-
1
,
-
1
,
id
.
job
,
id
.
rank
);
...
...
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