Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Xin Wang
codes-dev
Commits
f2711d79
Commit
f2711d79
authored
Jul 29, 2015
by
Jonathan Jenkins
Browse files
rename jobmap-list vars to be clearer
parent
cb3aed49
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/util/jobmap-impl/jobmap-list.c
View file @
f2711d79
...
...
@@ -29,8 +29,8 @@
struct
jobmap_list
{
int
num_jobs
;
int
*
num_
rank_
job
;
int
**
lp_array
s
;
int
*
rank_
counts
;
int
**
global_id
s
;
};
#define COND_REALLOC(_len_expr, _cap_var, _buf_var) \
...
...
@@ -115,10 +115,10 @@ static int jobmap_list_configure(void const * params, void ** ctx)
// job storage
lst
->
num_jobs
=
0
;
int
job_cap
=
8
;
lst
->
num_
rank_
job
=
calloc
(
job_cap
,
sizeof
(
*
lst
->
num_
rank_
job
));
assert
(
lst
->
num_
rank_
job
);
lst
->
lp_array
s
=
calloc
(
job_cap
,
sizeof
(
*
lst
->
lp_array
s
));
assert
(
lst
->
lp_array
s
);
lst
->
rank_
counts
=
calloc
(
job_cap
,
sizeof
(
*
lst
->
rank_
counts
));
assert
(
lst
->
rank_
counts
);
lst
->
global_id
s
=
calloc
(
job_cap
,
sizeof
(
*
lst
->
global_id
s
));
assert
(
lst
->
global_id
s
);
// line storage
int
line_cap
=
1
<<
10
;
...
...
@@ -128,8 +128,8 @@ static int jobmap_list_configure(void const * params, void ** ctx)
int
rc
=
0
;
do
{
rc
=
parse_line
(
f
,
&
line_buf
,
&
line_cap
,
&
lst
->
num_
rank_
job
[
lst
->
num_jobs
],
&
lst
->
lp_array
s
[
lst
->
num_jobs
]);
&
lst
->
rank_
counts
[
lst
->
num_jobs
],
&
lst
->
global_id
s
[
lst
->
num_jobs
]);
if
(
rc
==
-
1
)
{
// error and exit
if
(
ferror
(
f
))
{
...
...
@@ -137,14 +137,14 @@ static int jobmap_list_configure(void const * params, void ** ctx)
break
;
}
}
else
if
(
lst
->
num_
rank_
job
[
lst
->
num_jobs
]
>
0
)
{
else
if
(
lst
->
rank_
counts
[
lst
->
num_jobs
]
>
0
)
{
lst
->
num_jobs
++
;
}
// resize if needed
if
(
!
feof
(
f
)
&&
lst
->
num_jobs
==
job_cap
)
{
int
tmp
=
job_cap
;
COND_REALLOC
(
lst
->
num_jobs
,
tmp
,
lst
->
num_
rank_
job
);
COND_REALLOC
(
lst
->
num_jobs
,
job_cap
,
lst
->
lp_array
s
);
COND_REALLOC
(
lst
->
num_jobs
,
tmp
,
lst
->
rank_
counts
);
COND_REALLOC
(
lst
->
num_jobs
,
job_cap
,
lst
->
global_id
s
);
}
}
while
(
!
feof
(
f
));
...
...
@@ -156,10 +156,10 @@ static int jobmap_list_configure(void const * params, void ** ctx)
}
else
{
for
(
int
i
=
0
;
i
<
job_cap
;
i
++
)
{
free
(
lst
->
lp_array
s
[
i
]);
free
(
lst
->
global_id
s
[
i
]);
}
free
(
lst
->
lp_array
s
);
free
(
lst
->
num_
rank_
job
);
free
(
lst
->
global_id
s
);
free
(
lst
->
rank_
counts
);
free
(
lst
);
*
ctx
=
NULL
;
return
-
1
;
...
...
@@ -175,8 +175,8 @@ static struct codes_jobmap_id jobmap_list_to_local(int id, void const * ctx)
struct
jobmap_list
*
lst
=
(
struct
jobmap_list
*
)
ctx
;
for
(
int
i
=
0
;
i
<
lst
->
num_jobs
;
i
++
)
{
for
(
int
j
=
0
;
j
<
lst
->
num_
rank_
job
[
i
];
j
++
)
{
if
(
id
==
lst
->
lp_array
s
[
i
][
j
])
{
for
(
int
j
=
0
;
j
<
lst
->
rank_
counts
[
i
];
j
++
)
{
if
(
id
==
lst
->
global_id
s
[
i
][
j
])
{
rtn
.
job
=
i
;
rtn
.
rank
=
j
;
return
rtn
;
...
...
@@ -192,7 +192,7 @@ static int jobmap_list_to_global(struct codes_jobmap_id id, void const * ctx)
struct
jobmap_list
*
lst
=
(
struct
jobmap_list
*
)
ctx
;
if
(
id
.
job
<
lst
->
num_jobs
)
return
lst
->
lp_array
s
[
id
.
job
][
id
.
rank
];
return
lst
->
global_id
s
[
id
.
job
][
id
.
rank
];
else
return
-
1
;
}
...
...
@@ -208,11 +208,11 @@ static void jobmap_list_destroy(void * ctx)
{
struct
jobmap_list
*
lst
=
(
struct
jobmap_list
*
)
ctx
;
for
(
int
i
=
0
;
i
<
lst
->
num_jobs
;
i
++
){
free
(
lst
->
lp_array
s
[
i
]);
free
(
lst
->
global_id
s
[
i
]);
}
free
(
lst
->
lp_array
s
);
free
(
lst
->
num_
rank_
job
);
free
(
lst
->
global_id
s
);
free
(
lst
->
rank_
counts
);
free
(
ctx
);
}
...
...
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