Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
codes
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
38
Issues
38
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
codes
codes
Commits
ccb2567a
Commit
ccb2567a
authored
Jul 22, 2015
by
yangxuserene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up for jobmap interface based on John's suggestions
parent
3a2e6194
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
34 deletions
+45
-34
src/Makefile.subdir
src/Makefile.subdir
+1
-1
src/util/codes-jobmap.c
src/util/codes-jobmap.c
+2
-2
src/util/jobmap-impl/jobmap-list.c
src/util/jobmap-impl/jobmap-list.c
+42
-31
No files found.
src/Makefile.subdir
View file @
ccb2567a
...
...
@@ -99,7 +99,7 @@ src_libcodes_base_a_SOURCES = \
src/util/codes-jobmap-method-impl.h
\
src/util/codes-jobmap.c
\
src/util/jobmap-impl/jobmap-dummy.c
\
src/util/jobmap-impl/jobmap-l
ocal-global-mapping
.c
\
src/util/jobmap-impl/jobmap-l
ist
.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 @
ccb2567a
...
...
@@ -11,7 +11,7 @@
#include "codes/codes-jobmap.h"
extern
struct
codes_jobmap_impl
jobmap_dummy_impl
;
extern
struct
codes_jobmap_impl
jobmap_
dumpi
_impl
;
extern
struct
codes_jobmap_impl
jobmap_
list
_impl
;
struct
codes_jobmap_ctx
*
codes_jobmap_configure
(
enum
codes_jobmap_type
t
,
void
const
*
params
)
...
...
@@ -26,7 +26,7 @@ codes_jobmap_configure(enum codes_jobmap_type t, void const * params)
c
->
impl
=
&
jobmap_dummy_impl
;
break
;
case
CODES_JOBMAP_DUMPI
:
c
->
impl
=
&
jobmap_
dumpi
_impl
;
c
->
impl
=
&
jobmap_
list
_impl
;
break
;
default:
free
(
c
);
...
...
src/util/jobmap-impl/jobmap-l
ocal-global-mapping
.c
→
src/util/jobmap-impl/jobmap-l
ist
.c
View file @
ccb2567a
...
...
@@ -9,6 +9,11 @@
#include <assert.h>
#include "src/util/codes-jobmap-method-impl.h"
#define ERR(str, ...)\
do{\
fprintf(stderr, "ERROR at %s:%d: " str "\n", __FILE__, __LINE__, ##__VA_ARGS__);\
return -1; \
}while(0)
struct
workload_params
{
int
num_jobs
;
...
...
@@ -16,18 +21,16 @@ struct workload_params {
int
**
lp_arrays
;
};
static
int
jobmap_
dumpi
_configure
(
void
const
*
params
,
void
**
ctx
)
static
int
jobmap_
list
_configure
(
void
const
*
params
,
void
**
ctx
)
{
struct
codes_jobmap_params_dumpi
const
*
p
=
params
;
struct
workload_params
*
wp
=
malloc
(
sizeof
(
*
wp
));
assert
(
wp
);
/*open first time, count No. lines, each line is the LP list for a job*/
FILE
*
alloc_file_name
=
fopen
(
p
->
alloc_file
,
"r"
);
if
(
!
alloc_file_name
)
{
printf
(
"Coudld not open file %s ======
\n
"
,
p
->
alloc_file
);
exit
(
1
);
ERR
(
"Coudld not open file %s
\n
"
,
p
->
alloc_file
);
}
else
{
wp
->
num_jobs
=
0
;
...
...
@@ -37,38 +40,37 @@ static int jobmap_dumpi_configure(void const * params, void ** ctx)
if
(
ch
==
'\n'
)
wp
->
num_jobs
++
;
//how many jobs
}
fclose
(
alloc_file_name
);
}
wp
->
num_rank_job
=
malloc
(
sizeof
(
wp
->
num_rank_job
)
*
wp
->
num_jobs
);
assert
(
wp
->
num_rank_job
);
for
(
int
i
=
0
;
i
<
wp
->
num_jobs
;
i
++
)
wp
->
num_rank_job
[
i
]
=
0
;
/*open second time, read No. of LP id in each line, No. of LP id equals to No. of rank in each job*/
alloc_file_name
=
fopen
(
p
->
alloc_file
,
"r"
);
int
job_id
=
0
;
while
(
!
feof
(
alloc_file_name
))
rewind
(
alloc_file_name
);
{
char
ch
=
(
char
)
fgetc
(
alloc_file_name
);
if
(
ch
==
'\n'
){
job_id
++
;
//how many jobs
continue
;
}
if
(
ch
==
' '
){
wp
->
num_rank_job
[
job_id
]
++
;
//how many ranks in each job
int
job_id
=
0
;
while
(
!
feof
(
alloc_file_name
))
{
char
ch
=
(
char
)
fgetc
(
alloc_file_name
);
if
(
ch
==
'\n'
){
job_id
++
;
//how many jobs
continue
;
}
if
(
ch
==
' '
){
wp
->
num_rank_job
[
job_id
]
++
;
//how many ranks in each job
}
}
}
fclose
(
alloc_file_name
);
/*open third time, read in each LP id for each rank in every job*/
wp
->
lp_arrays
=
(
int
**
)
malloc
(
sizeof
(
int
*
)
*
wp
->
num_jobs
);
for
(
int
i
=
0
;
i
<
wp
->
num_jobs
;
i
++
){
wp
->
lp_arrays
[
i
]
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
wp
->
num_rank_job
[
i
]);
}
alloc_file_name
=
fopen
(
p
->
alloc_file
,
"r"
);
rewind
(
alloc_file_name
);
for
(
int
i
=
0
;
i
<
wp
->
num_jobs
;
i
++
)
{
for
(
int
j
=
0
;
j
<
wp
->
num_rank_job
[
i
];
j
++
)
...
...
@@ -86,7 +88,7 @@ static int jobmap_dumpi_configure(void const * params, void ** ctx)
printf
(
"
\n
In Job %d, there are %d ranks, LP list is:
\n
"
,
i
,
wp
->
num_rank_job
[
i
]);
for
(
int
j
=
0
;
j
<
wp
->
num_rank_job
[
i
];
j
++
)
{
printf
(
"
,
%d,"
,
wp
->
lp_arrays
[
i
][
j
]);
printf
(
"%d,"
,
wp
->
lp_arrays
[
i
][
j
]);
}
printf
(
"
\n
==========
\n
"
);
}
...
...
@@ -94,7 +96,7 @@ static int jobmap_dumpi_configure(void const * params, void ** ctx)
return
0
;
}
static
struct
codes_jobmap_id
jobmap_
dumpi
_to_local
(
int
id
,
void
const
*
ctx
)
static
struct
codes_jobmap_id
jobmap_
list
_to_local
(
int
id
,
void
const
*
ctx
)
{
struct
codes_jobmap_id
rtn
;
struct
workload_params
*
wp
=
(
struct
workload_params
*
)
ctx
;
...
...
@@ -119,7 +121,7 @@ static struct codes_jobmap_id jobmap_dumpi_to_local(int id, void const * ctx)
return
rtn
;
}
static
int
jobmap_
dumpi
_to_global
(
struct
codes_jobmap_id
id
,
void
const
*
ctx
)
static
int
jobmap_
list
_to_global
(
struct
codes_jobmap_id
id
,
void
const
*
ctx
)
{
struct
workload_params
*
wp
=
(
struct
workload_params
*
)
ctx
;
...
...
@@ -130,7 +132,7 @@ static int jobmap_dumpi_to_global(struct codes_jobmap_id id, void const * ctx)
return
-
1
;
}
int
jobmap_
dumpi
_get_num_jobs
(
void
const
*
ctx
)
int
jobmap_
list
_get_num_jobs
(
void
const
*
ctx
)
{
struct
workload_params
*
wp
=
(
struct
workload_params
*
)
ctx
;
return
wp
->
num_jobs
;
...
...
@@ -138,18 +140,27 @@ int jobmap_dumpi_get_num_jobs(void const * ctx)
}
static
void
jobmap_
dumpi
_destroy
(
void
*
ctx
)
static
void
jobmap_
list
_destroy
(
void
*
ctx
)
{
struct
workload_params
*
wp
=
(
struct
workload_params
*
)
ctx
;
for
(
int
i
=
0
;
i
<
wp
->
num_jobs
;
i
++
){
free
(
wp
->
lp_arrays
[
i
]);
}
free
(
wp
->
lp_arrays
);
free
(
wp
->
num_rank_job
);
free
(
ctx
);
}
struct
codes_jobmap_impl
jobmap_
dumpi
_impl
=
{
jobmap_
dumpi
_configure
,
jobmap_
dumpi
_destroy
,
jobmap_
dumpi
_to_local
,
jobmap_
dumpi
_to_global
,
jobmap_
dumpi
_get_num_jobs
struct
codes_jobmap_impl
jobmap_
list
_impl
=
{
jobmap_
list
_configure
,
jobmap_
list
_destroy
,
jobmap_
list
_to_local
,
jobmap_
list
_to_global
,
jobmap_
list
_get_num_jobs
};
/*
...
...
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