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
Xin Wang
codes-dev
Commits
a34a36d0
Commit
a34a36d0
authored
Apr 28, 2014
by
Jonathan Jenkins
Browse files
fixes and tweaks to resource LP, plus test prog
parent
7a94693d
Changes
5
Hide whitespace changes
Inline
Side-by-side
codes/resource-lp.h
View file @
a34a36d0
...
...
@@ -24,16 +24,14 @@ typedef struct {
}
resource_callback
;
void
resource_lp_init
();
void
resource_lp_configure
();
/* Wrappers for the underlying resource structure.
* Implicitly maps the given LPID to it's group and repetition, then messages
* the resource LP with the request.
* Msg_size is where to
* The "set" function is the initializer, to be called by exactly one LP in the
* group that contains the resource to initialize */
void
resource_lp_set
(
tw_lpid
src
,
uint64_t
avail
);
/* The following functions expect the sending LP to put its gid in the
* header->src field, along with its magic and callback event type */
* The following functions expect the sending LP to put its magic and callback
* event type into the header parameter (lpid not necessary, it's grabbed from
* sender) */
void
resource_lp_get
(
msg_header
*
header
,
uint64_t
req
,
...
...
@@ -42,7 +40,7 @@ void resource_lp_get(
int
msg_callback_offset
,
tw_lp
*
sender
);
/* no callback for frees thus far */
void
resource_lp_free
(
msg_header
*
header
,
uint64_t
req
,
tw_lp
*
sender
);
void
resource_lp_free
(
uint64_t
req
,
tw_lp
*
sender
);
void
resource_lp_reserve
(
msg_header
*
header
,
uint64_t
req
,
...
...
@@ -59,7 +57,6 @@ void resource_lp_get_reserved(
int
msg_callback_offset
,
tw_lp
*
sender
);
void
resource_lp_free_reserved
(
msg_header
*
header
,
uint64_t
req
,
resource_token_t
tok
,
tw_lp
*
sender
);
...
...
src/util/resource-lp.c
View file @
a34a36d0
...
...
@@ -160,8 +160,8 @@ void resource_event_handler(
c
.
tok
=
tok
;
/* before we send the message, sanity check the sizes */
if
(
m
->
msg_size
<
=
m
->
msg_header_offset
+
sizeof
(
h
)
&&
m
->
msg_size
<
=
m
->
msg_callback_offset
+
sizeof
(
c
)){
if
(
m
->
msg_size
>
=
m
->
msg_header_offset
+
sizeof
(
h
)
&&
m
->
msg_size
>
=
m
->
msg_callback_offset
+
sizeof
(
c
)){
tw_event
*
e
=
codes_event_new
(
m
->
h_callback
.
src
,
codes_local_latency
(
lp
),
lp
);
void
*
msg
=
tw_event_data
(
e
);
...
...
@@ -278,12 +278,14 @@ static void resource_lp_issue_event(
/* set message info */
resource_msg
*
m
=
tw_event_data
(
e
);
msg_set_header
(
header
->
src
,
resource_magic
,
type
,
&
m
->
h
);
msg_set_header
(
resource_magic
,
type
,
sender
->
gid
,
&
m
->
h
);
m
->
req
=
req
;
m
->
tok
=
tok
;
/* set callback info */
m
->
h_callback
=
*
header
;
if
(
header
!=
NULL
){
m
->
h_callback
=
*
header
;
}
m
->
msg_size
=
msg_size
;
m
->
msg_header_offset
=
msg_header_offset
;
m
->
msg_callback_offset
=
msg_callback_offset
;
...
...
@@ -303,8 +305,8 @@ void resource_lp_get(
}
/* no callback for frees thus far */
void
resource_lp_free
(
msg_header
*
header
,
uint64_t
req
,
tw_lp
*
sender
){
resource_lp_issue_event
(
header
,
req
,
TOKEN_DUMMY
,
-
1
,
-
1
,
-
1
,
void
resource_lp_free
(
uint64_t
req
,
tw_lp
*
sender
){
resource_lp_issue_event
(
NULL
,
req
,
TOKEN_DUMMY
,
-
1
,
-
1
,
-
1
,
RESOURCE_FREE
,
sender
);
}
void
resource_lp_reserve
(
...
...
@@ -330,11 +332,10 @@ void resource_lp_get_reserved(
sender
);
}
void
resource_lp_free_reserved
(
msg_header
*
header
,
uint64_t
req
,
resource_token_t
tok
,
tw_lp
*
sender
){
resource_lp_issue_event
(
header
,
req
,
tok
,
-
1
,
-
1
,
-
1
,
RESOURCE_FREE_RESERVED
,
resource_lp_issue_event
(
NULL
,
req
,
tok
,
-
1
,
-
1
,
-
1
,
RESOURCE_FREE_RESERVED
,
sender
);
}
...
...
src/util/resource.c
View file @
a34a36d0
...
...
@@ -46,7 +46,7 @@ int resource_reserve(uint64_t req, resource_token_t *tok, resource *r){
}
}
/* Acquire req units of the resource from a reserved pool */
/* Acquire req units of the resource from a reserved pool */
int
reserved_get
(
uint64_t
req
,
resource_token_t
tok
,
resource
*
r
){
assert
(
tok
<
r
->
num_tokens
);
if
(
req
>
r
->
reserved_avail
[
tok
]){
...
...
tests/Makefile.subdir
View file @
a34a36d0
...
...
@@ -2,7 +2,8 @@
check_PROGRAMS
+=
tests/lp-io-test
\
tests/workload/codes-workload-test
\
tests/workload/codes-workload-mpi-replay
\
tests/mapping_test
tests/mapping_test
\
tests/resource-test
TESTS
+=
tests/lp-io-test.sh
\
tests/workload/codes-workload-test.sh
\
...
...
@@ -22,6 +23,10 @@ tests_mapping_test_LDADD = $(testlib) ${ROSS_LIBS}
tests_mapping_test_LDFLAGS
=
${ROSS_LDFLAGS}
tests_mapping_test_SOURCES
=
tests/mapping_test.c
tests_resource_test_LDADD
=
$(testlib)
${ROSS_LIBS}
tests_resource_test_LDFLAGS
=
${ROSS_LDFLAGS}
tests_resource_test_SOURCES
=
tests/resource-test.c
tests_workload_codes_workload_test_LDADD
=
$(testlib)
${ROSS_LIBS}
tests_workload_codes_workload_test_LDFLAGS
=
${ROSS_LDFLAGS}
tests_workload_codes_workload_test_SOURCES
=
\
...
...
tests/resource-test.c
0 → 100644
View file @
a34a36d0
/*
* Copyright (C) 2014 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#include
"codes/resource.h"
#include
"codes/resource-lp.h"
#include
"codes/lp-msg.h"
#include
"codes/configuration.h"
#include
"codes/codes_mapping.h"
#include
<stdint.h>
static
int
bsize
=
1024
;
static
int
s_magic
=
12345
;
enum
s_type
{
S_KICKOFF
,
S_ALLOC_ACK
,
S_FREE
,
};
typedef
struct
{
int
id
;
uint64_t
mem
,
mem_max
;
}
s_state
;
typedef
struct
{
msg_header
h
;
resource_callback
c
;
uint64_t
mem_max_prev
;
}
s_msg
;
static
void
s_init
(
s_state
*
ns
,
tw_lp
*
lp
){
ns
->
mem
=
0
;
ns
->
mem_max
=
0
;
ns
->
id
=
codes_mapping_get_lp_global_rel_id
(
lp
->
gid
);
tw_event
*
e
=
codes_event_new
(
lp
->
gid
,
codes_local_latency
(
lp
),
lp
);
s_msg
*
m
=
tw_event_data
(
e
);
msg_set_header
(
s_magic
,
S_KICKOFF
,
lp
->
gid
,
&
m
->
h
);
tw_event_send
(
e
);
}
static
void
s_finalize
(
s_state
*
ns
,
tw_lp
*
lp
){
printf
(
"Server %d got %lu memory before failing
\n
"
,
ns
->
id
,
ns
->
mem_max
);
}
static
void
s_event
(
s_state
*
ns
,
tw_bf
*
bf
,
s_msg
*
m
,
tw_lp
*
lp
){
assert
(
m
->
h
.
magic
==
s_magic
);
switch
(
m
->
h
.
event_type
){
case
S_KICKOFF
:
;
msg_header
h
;
msg_set_header
(
s_magic
,
S_ALLOC_ACK
,
lp
->
gid
,
&
h
);
resource_lp_get
(
&
h
,
bsize
,
sizeof
(
s_msg
),
offsetof
(
s_msg
,
h
),
offsetof
(
s_msg
,
c
),
lp
);
break
;
case
S_ALLOC_ACK
:
if
(
m
->
c
.
ret
==
0
){
ns
->
mem
+=
bsize
;
m
->
mem_max_prev
=
ns
->
mem_max
;
ns
->
mem_max
=
max
(
ns
->
mem
,
ns
->
mem_max
);
msg_header
h
;
msg_set_header
(
s_magic
,
S_ALLOC_ACK
,
lp
->
gid
,
&
h
);
resource_lp_get
(
&
h
,
bsize
,
sizeof
(
s_msg
),
offsetof
(
s_msg
,
h
),
offsetof
(
s_msg
,
c
),
lp
);
break
;
}
/* else fall into the free stmt */
case
S_FREE
:
resource_lp_free
(
bsize
,
lp
);
ns
->
mem
-=
bsize
;
if
(
ns
->
mem
>
0
){
tw_event
*
e
=
codes_event_new
(
lp
->
gid
,
codes_local_latency
(
lp
),
lp
);
s_msg
*
m
=
tw_event_data
(
e
);
msg_set_header
(
s_magic
,
S_FREE
,
lp
->
gid
,
&
m
->
h
);
tw_event_send
(
e
);
}
break
;
}
}
static
void
s_event_rc
(
s_state
*
ns
,
tw_bf
*
b
,
s_msg
*
m
,
tw_lp
*
lp
){
assert
(
m
->
h
.
magic
==
s_magic
);
switch
(
m
->
h
.
event_type
){
case
S_KICKOFF
:
resource_lp_get_rc
(
lp
);
break
;
case
S_ALLOC_ACK
:
if
(
m
->
c
.
ret
==
0
){
ns
->
mem
-=
bsize
;
ns
->
mem_max
=
m
->
mem_max_prev
;
resource_lp_get_rc
(
lp
);
break
;
}
/* else fall into the free stmt */
case
S_FREE
:
/* undoing is unconditional given this lps logic */
resource_lp_free_rc
(
lp
);
if
(
ns
->
mem
>
0
){
codes_local_latency_reverse
(
lp
);
}
ns
->
mem
+=
bsize
;
}
}
static
tw_lptype
s_lp
=
{
(
init_f
)
s_init
,
(
event_f
)
s_event
,
(
revent_f
)
s_event_rc
,
(
final_f
)
s_finalize
,
(
map_f
)
codes_mapping
,
sizeof
(
s_state
),
};
static
char
conf_file_name
[
128
]
=
{
'\0'
};
static
const
tw_optdef
app_opt
[]
=
{
TWOPT_GROUP
(
"codes-mapping test case"
),
TWOPT_CHAR
(
"codes-config"
,
conf_file_name
,
"name of codes configuration file"
),
TWOPT_END
()
};
int
main
(
int
argc
,
char
*
argv
[])
{
g_tw_ts_end
=
1e9
*
60
*
60
*
24
*
365
;
/* one year, in nsecs */
tw_opt_add
(
app_opt
);
tw_init
(
&
argc
,
&
argv
);
if
(
!
conf_file_name
[
0
]){
fprintf
(
stderr
,
"Expected
\"
codes-config
\"
option, please see --help.
\n
"
);
MPI_Finalize
();
return
1
;
}
if
(
configuration_load
(
conf_file_name
,
MPI_COMM_WORLD
,
&
config
)){
fprintf
(
stderr
,
"Error loading config file %s.
\n
"
,
conf_file_name
);
MPI_Finalize
();
return
1
;
}
resource_lp_init
();
lp_type_register
(
"server"
,
&
s_lp
);
codes_mapping_setup
();
resource_lp_configure
();
tw_run
();
tw_end
();
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
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