Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
codes-dev
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xin Wang
codes-dev
Commits
2353fb13
Commit
2353fb13
authored
Jul 29, 2015
by
Jonathan Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an "identity" jobmap implementation (one job, N ranks)
parent
37c64789
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
128 additions
and
5 deletions
+128
-5
codes/codes-jobmap.h
codes/codes-jobmap.h
+14
-3
src/Makefile.subdir
src/Makefile.subdir
+1
-0
src/util/codes-jobmap.c
src/util/codes-jobmap.c
+6
-2
src/util/jobmap-impl/jobmap-identity.c
src/util/jobmap-impl/jobmap-identity.c
+78
-0
tests/jobmap-test.c
tests/jobmap-test.c
+29
-0
No files found.
codes/codes-jobmap.h
View file @
2353fb13
...
...
@@ -23,10 +23,21 @@
/** type markers and parameter defs for jobmaps **/
enum
codes_jobmap_type
{
/* the "dummy" jobmap is an example implementation. It simply specifies N
* jobs, with exactly one rank per job, with a trivial mapping */
/* the "identity" jobmap is a shim for single-job workloads */
CODES_JOBMAP_IDENTITY
,
/* the "list" jobmap allows the explicit specification of mappings from
* jobs to lists of global ids through a text file, wiht one line per job
*/
CODES_JOBMAP_LIST
,
/* the "dummy" jobmap is an example implementation for testing, and can be
* seen as the inverse of the identity mapping.
* It simply specifies N jobs, with exactly one rank per job, with a trivial
* mapping */
CODES_JOBMAP_DUMMY
,
CODES_JOBMAP_LIST
};
struct
codes_jobmap_params_identity
{
int
num_ranks
;
};
struct
codes_jobmap_params_dummy
{
...
...
src/Makefile.subdir
View file @
2353fb13
...
...
@@ -101,6 +101,7 @@ src_libcodes_base_a_SOURCES = \
src/util/codes-jobmap.c
\
src/util/jobmap-impl/jobmap-dummy.c
\
src/util/jobmap-impl/jobmap-list.c
\
src/util/jobmap-impl/jobmap-identity.c
\
src/workload/codes-workload.c
\
src/workload/codes-workload-method.h
\
src/workload/methods/codes-iolang-wrkld.c
\
...
...
src/util/codes-jobmap.c
View file @
2353fb13
...
...
@@ -12,6 +12,7 @@
extern
struct
codes_jobmap_impl
jobmap_dummy_impl
;
extern
struct
codes_jobmap_impl
jobmap_list_impl
;
extern
struct
codes_jobmap_impl
jobmap_identity_impl
;
struct
codes_jobmap_ctx
*
codes_jobmap_configure
(
enum
codes_jobmap_type
t
,
void
const
*
params
)
...
...
@@ -22,12 +23,15 @@ codes_jobmap_configure(enum codes_jobmap_type t, void const * params)
c
->
type
=
t
;
switch
(
t
)
{
case
CODES_JOBMAP_
DUMM
Y
:
c
->
impl
=
&
jobmap_
dumm
y_impl
;
case
CODES_JOBMAP_
IDENTIT
Y
:
c
->
impl
=
&
jobmap_
identit
y_impl
;
break
;
case
CODES_JOBMAP_LIST
:
c
->
impl
=
&
jobmap_list_impl
;
break
;
case
CODES_JOBMAP_DUMMY
:
c
->
impl
=
&
jobmap_dummy_impl
;
break
;
default:
free
(
c
);
fprintf
(
stderr
,
"ERROR: unknown jobmap type %d
\n
"
,
t
);
...
...
src/util/jobmap-impl/jobmap-identity.c
0 → 100644
View file @
2353fb13
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#include <stdlib.h>
#include <assert.h>
#include "../codes-jobmap-method-impl.h"
static
int
jobmap_identity_configure
(
void
const
*
params
,
void
**
ctx
)
{
int
*
num_ranks
=
malloc
(
sizeof
(
*
num_ranks
));
assert
(
num_ranks
);
*
ctx
=
num_ranks
;
struct
codes_jobmap_params_identity
const
*
p
=
params
;
*
num_ranks
=
p
->
num_ranks
;
return
0
;
}
static
void
jobmap_identity_destroy
(
void
*
ctx
)
{
free
(
ctx
);
}
static
struct
codes_jobmap_id
jobmap_identity_to_local
(
int
id
,
void
const
*
ctx
)
{
int
const
*
num_ranks
=
ctx
;
struct
codes_jobmap_id
rtn
;
if
(
id
<
0
||
id
>=
*
num_ranks
)
{
rtn
.
job
=
-
1
;
rtn
.
rank
=
-
1
;
}
else
{
rtn
.
job
=
0
;
rtn
.
rank
=
id
;
}
return
rtn
;
}
static
int
jobmap_identity_to_global
(
struct
codes_jobmap_id
id
,
void
const
*
ctx
)
{
int
const
*
num_ranks
=
ctx
;
if
(
id
.
job
>=
1
||
id
.
rank
>=
*
num_ranks
||
id
.
job
<
0
||
id
.
rank
<
0
)
return
-
1
;
else
return
id
.
rank
;
}
int
jobmap_identity_get_num_jobs
(
void
const
*
ctx
)
{
return
1
;
}
struct
codes_jobmap_impl
jobmap_identity_impl
=
{
jobmap_identity_configure
,
jobmap_identity_destroy
,
jobmap_identity_to_local
,
jobmap_identity_to_global
,
jobmap_identity_get_num_jobs
};
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
tests/jobmap-test.c
View file @
2353fb13
...
...
@@ -14,6 +14,33 @@
return 1; \
} while(0)
static
int
test_jobmap_identity
(
int
num_ranks
)
{
struct
codes_jobmap_ctx
*
c
;
struct
codes_jobmap_params_identity
p
;
c
=
codes_jobmap_configure
(
CODES_JOBMAP_IDENTITY
,
&
p
);
if
(
!
c
)
ERR
(
"jobmap-identity: configure failure"
);
int
num_jobs
=
codes_jobmap_get_num_jobs
(
c
);
if
(
1
!=
num_jobs
)
ERR
(
"jobmap-identity: expected exactly 1 job, got %d
\n
"
,
num_jobs
);
struct
codes_jobmap_id
lid
;
int
gid
;
for
(
int
i
=
0
;
i
<
num_ranks
;
i
++
)
{
lid
.
job
=
-
1
;
lid
.
rank
=
-
1
;
lid
=
codes_jobmap_to_local_id
(
i
,
c
);
if
(
lid
.
job
!=
0
||
lid
.
rank
!=
i
)
ERR
(
"jobmap-identity: expected lid (%d,%d), got (%d,%d) for gid %d"
,
0
,
i
,
lid
.
job
,
lid
.
rank
,
i
);
gid
=
codes_jobmap_to_global_id
(
lid
,
c
);
if
(
gid
!=
i
)
ERR
(
"jobmap-identity: expected gid %d, got %d for lid (%d,%d)"
,
i
,
gid
,
lid
.
job
,
lid
.
rank
);
}
return
0
;
}
/* THIS TEST IS HARDCODED AGAINST jobmap-test-list.conf */
static
int
test_jobmap_list
(
char
*
fname
)
{
...
...
@@ -109,6 +136,8 @@ int main(int argc, char *argv[])
int
rc
;
rc
=
test_jobmap_dummy
(
10
);
if
(
rc
)
return
rc
;
rc
=
test_jobmap_identity
(
10
);
if
(
rc
)
return
rc
;
rc
=
test_jobmap_list
(
argv
[
1
]);
if
(
rc
)
return
rc
;
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