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
Elsa Gonsiorowski
codes
Commits
f8ebb23d
Commit
f8ebb23d
authored
Jun 29, 2015
by
yangxuserene
Browse files
test merge
parents
3d917701
3bfbd0c6
Changes
6
Hide whitespace changes
Inline
Side-by-side
codes/codes-jobmap.h
View file @
f8ebb23d
...
@@ -11,9 +11,9 @@
...
@@ -11,9 +11,9 @@
*
*
* Example:
* Example:
*
*
* job 0 1 2
* job 0 1 2
(<-- jobmap defined "local" IDs)
* rank 0 1 2 0 1 0 1 2 3
* 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 ID)
* 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)
* 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);
...
@@ -46,10 +46,20 @@ codes_jobmap_configure(enum codes_jobmap_type t, void const * params);
void
codes_jobmap_destroy
(
struct
codes_jobmap_ctx
*
c
);
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
,
int
id
,
struct
codes_jobmap_ctx
const
*
c
);
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
);
int
codes_jobmap_get_num_jobs
(
struct
codes_jobmap_ctx
const
*
c
);
#endif
#endif
...
...
src/util/codes-jobmap-method-impl.h
View file @
f8ebb23d
...
@@ -13,10 +13,11 @@
...
@@ -13,10 +13,11 @@
struct
codes_jobmap_impl
{
struct
codes_jobmap_impl
{
/* returns nonzero on failure (to distinguish between no-state (dummy) and
/* returns nonzero on failure (to distinguish between no-state (dummy) and
* failure) */
* failure) */
int
(
*
configure
)(
void
const
*
params
,
void
**
ctx
);
int
(
*
configure
)(
void
const
*
params
,
void
**
ctx
);
void
(
*
destroy
)(
void
*
ctx
);
void
(
*
destroy
)(
void
*
ctx
);
struct
codes_jobmap_id
(
*
lookup
)
(
int
id
,
void
const
*
ctx
);
struct
codes_jobmap_id
(
*
to_local
)
(
int
id
,
void
const
*
ctx
);
int
(
*
get_num_jobs
)(
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
{
struct
codes_jobmap_ctx
{
...
...
src/util/codes-jobmap.c
View file @
f8ebb23d
...
@@ -45,11 +45,18 @@ void codes_jobmap_destroy(struct codes_jobmap_ctx *c)
...
@@ -45,11 +45,18 @@ void codes_jobmap_destroy(struct codes_jobmap_ctx *c)
free
(
c
);
free
(
c
);
}
}
struct
codes_jobmap_id
codes_jobmap_
lookup
(
struct
codes_jobmap_id
codes_jobmap_
to_local_id
(
int
id
,
int
id
,
struct
codes_jobmap_ctx
const
*
c
)
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
)
int
codes_jobmap_get_num_jobs
(
struct
codes_jobmap_ctx
const
*
c
)
...
...
src/util/jobmap-impl/jobmap-dummy.c
View file @
f8ebb23d
...
@@ -11,9 +11,9 @@
...
@@ -11,9 +11,9 @@
static
int
jobmap_dummy_configure
(
void
const
*
params
,
void
**
ctx
)
static
int
jobmap_dummy_configure
(
void
const
*
params
,
void
**
ctx
)
{
{
int
*
num_jobs
=
*
ctx
;
int
*
num_jobs
=
malloc
(
sizeof
(
*
num_jobs
));
num_jobs
=
malloc
(
sizeof
(
*
num_jobs
));
assert
(
num_jobs
);
assert
(
num_jobs
);
*
ctx
=
num_jobs
;
struct
codes_jobmap_params_dummy
const
*
p
=
params
;
struct
codes_jobmap_params_dummy
const
*
p
=
params
;
...
@@ -27,18 +27,34 @@ static void jobmap_dummy_destroy(void * ctx)
...
@@ -27,18 +27,34 @@ static void jobmap_dummy_destroy(void * ctx)
free
(
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
;
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
.
job
=
id
;
rtn
.
rank
=
0
;
rtn
.
rank
=
0
;
}
}
else
{
rtn
.
job
=
-
1
;
rtn
.
rank
=
-
1
;
}
return
rtn
;
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
)
int
jobmap_dummy_get_num_jobs
(
void
const
*
ctx
)
{
{
return
*
(
int
const
*
)
ctx
;
return
*
(
int
const
*
)
ctx
;
...
@@ -47,7 +63,8 @@ int jobmap_dummy_get_num_jobs(void const * ctx)
...
@@ -47,7 +63,8 @@ int jobmap_dummy_get_num_jobs(void const * ctx)
struct
codes_jobmap_impl
jobmap_dummy_impl
=
{
struct
codes_jobmap_impl
jobmap_dummy_impl
=
{
jobmap_dummy_configure
,
jobmap_dummy_configure
,
jobmap_dummy_destroy
,
jobmap_dummy_destroy
,
jobmap_dummy_lookup
,
jobmap_dummy_to_local
,
jobmap_dummy_to_global
,
jobmap_dummy_get_num_jobs
jobmap_dummy_get_num_jobs
};
};
...
...
tests/Makefile.subdir
View file @
f8ebb23d
...
@@ -52,7 +52,7 @@ tests_rc_stack_test_SOURCES = tests/rc-stack-test.c
...
@@ -52,7 +52,7 @@ tests_rc_stack_test_SOURCES = tests/rc-stack-test.c
tests_jobmap_test_LDADD
=
$(testlib)
${ROSS_LIBS}
tests_jobmap_test_LDADD
=
$(testlib)
${ROSS_LIBS}
tests_jobmap_test_LDFLAGS
=
${ROSS_LDFLAGS}
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_LDADD
=
$(testlib)
${ROSS_LIBS}
tests_workload_codes_workload_test_LDFLAGS
=
${ROSS_LDFLAGS}
tests_workload_codes_workload_test_LDFLAGS
=
${ROSS_LDFLAGS}
...
...
tests/jobmap-test.c
View file @
f8ebb23d
...
@@ -8,41 +8,68 @@
...
@@ -8,41 +8,68 @@
#include "codes/codes-jobmap.h"
#include "codes/codes-jobmap.h"
const
int
N
=
10
;
int
main
(
int
argc
,
char
*
argv
[])
{
struct
codes_jobmap_ctx
*
c
;
struct
codes_jobmap_params_dummy
p
;
p
.
num_jobs
=
N
;
#define ERR(str, ...) \
#define ERR(str, ...) \
do { \
do { \
fprintf(stderr, "ERROR: " str "\n", ##__VA_ARGS__); \
fprintf(stderr, "ERROR
at %s:%d
: " str "\n",
__FILE__, __LINE__,
##__VA_ARGS__); \
return 1; \
return 1; \
} while(0)
} while(0)
static
int
test_jobmap_dummy
(
int
num_jobs
)
{
struct
codes_jobmap_ctx
*
c
;
struct
codes_jobmap_params_dummy
p
;
p
.
num_jobs
=
num_jobs
;
/* initialize */
/* initialize */
c
=
codes_jobmap_configure
(
CODES_JOBMAP_DUMMY
,
&
p
);
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
lid
;
struct
codes_jobmap_id
id
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
/* successful local lookups */
id
=
codes_jobmap_lookup
(
i
,
c
);
for
(
int
i
=
0
;
i
<
num_jobs
;
i
++
)
{
if
(
id
.
job
!=
i
||
id
.
rank
!=
0
)
lid
=
codes_jobmap_to_local_id
(
i
,
c
);
if
(
lid
.
job
!=
i
||
lid
.
rank
!=
0
)
ERR
(
"lookup failure for %d: expected (%d,%d), got (%d,%d)"
,
ERR
(
"lookup failure for %d: expected (%d,%d), got (%d,%d)"
,
i
,
i
,
0
,
id
.
job
,
id
.
rank
);
i
,
i
,
0
,
lid
.
job
,
lid
.
rank
);
else
{
lid
.
job
=
-
1
;
lid
.
rank
=
-
1
;
}
}
/* bad local lookup */
lid
=
codes_jobmap_to_local_id
(
num_jobs
,
c
);
if
(
lid
.
job
!=
-
1
||
lid
.
rank
!=
-
1
)
ERR
(
"lookup expected failure for %d: expected (%d,%d), got (%d,%d)"
,
num_jobs
,
-
1
,
-
1
,
lid
.
job
,
lid
.
rank
);
/* successful global lookups */
int
gid
;
lid
.
rank
=
0
;
for
(
lid
.
job
=
0
;
lid
.
job
<
num_jobs
;
lid
.
job
++
)
{
gid
=
codes_jobmap_to_global_id
(
lid
,
c
);
if
(
gid
!=
lid
.
job
)
ERR
(
"lookup failure for (%d,%d): expected %d, got %d"
,
lid
.
job
,
lid
.
rank
,
lid
.
job
,
gid
);
}
}
/* bad lookup */
/* bad global lookup */
id
=
codes_jobmap_lookup
(
10
,
c
);
lid
.
job
=
num_jobs
;
if
(
id
.
job
!=
-
1
||
id
.
rank
!=
-
1
)
gid
=
codes_jobmap_to_global_id
(
lid
,
c
);
ERR
(
"lookup expected failure for 10: expected (%d,%d), got (%d,%d)"
,
if
(
gid
!=
-
1
)
-
1
,
-
1
,
id
.
job
,
id
.
rank
);
ERR
(
"lookup expected failure for (%d,0): expected -1, got %d"
,
num_jobs
,
gid
);
/* cleanup */
/* cleanup */
codes_jobmap_destroy
(
c
);
codes_jobmap_destroy
(
c
);
#undef ERR
return
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
rc
;
rc
=
test_jobmap_dummy
(
10
);
if
(
rc
)
return
rc
;
return
0
;
return
0
;
}
}
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