Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-uggrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
staging
dune-uggrid
Commits
1e43c8d1
Commit
1e43c8d1
authored
6 years ago
by
Ansgar Burchardt
Browse files
Options
Downloads
Patches
Plain Diff
DDD: cmdmsg.cc: add state to context object
parent
3ca6684f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!96
DDD: move global state to a context object
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/uggrid/parallel/ddd/dddcontext.hh
+17
-0
17 additions, 0 deletions
dune/uggrid/parallel/ddd/dddcontext.hh
parallel/ddd/xfer/cmdmsg.cc
+24
-29
24 additions, 29 deletions
parallel/ddd/xfer/cmdmsg.cc
with
41 additions
and
29 deletions
dune/uggrid/parallel/ddd/dddcontext.hh
+
17
−
0
View file @
1e43c8d1
...
...
@@ -114,6 +114,16 @@ struct PrioContext
}
/* namespace Prio */
namespace
Xfer
{
struct
CmdmsgContext
{
Basic
::
LC_MSGTYPE
cmdmsg_t
;
Basic
::
LC_MSGCOMP
undelete_id
;
};
}
/* namespace Xfer */
struct
CouplingContext
{
std
::
vector
<
COUPLING
*>
cplTable
;
...
...
@@ -217,6 +227,12 @@ public:
const
Prio
::
PrioContext
&
prioContext
()
const
{
return
prioContext_
;
}
Xfer
::
CmdmsgContext
&
cmdmsgContext
()
{
return
cmdmsgContext_
;
}
const
Xfer
::
CmdmsgContext
&
cmdmsgContext
()
const
{
return
cmdmsgContext_
;
}
CouplingContext
&
couplingContext
()
{
return
couplingContext_
;
}
...
...
@@ -262,6 +278,7 @@ protected:
Mgr
::
TypemgrContext
typemgrContext_
;
Prio
::
PrioContext
prioContext_
;
CouplingContext
couplingContext_
;
Xfer
::
CmdmsgContext
cmdmsgContext_
;
std
::
vector
<
DDD_HDR
>
objTable_
;
int
nObjs_
;
...
...
This diff is collapsed.
Click to expand it.
parallel/ddd/xfer/cmdmsg.cc
+
24
−
29
View file @
1e43c8d1
...
...
@@ -80,21 +80,6 @@ struct CMDMSG
};
/****************************************************************************/
/* */
/* variables global to this source file only (static) */
/* */
/****************************************************************************/
static
LC_MSGTYPE
cmdmsg_t
;
static
LC_MSGCOMP
undelete_id
;
/****************************************************************************/
/* */
/* routines */
...
...
@@ -104,8 +89,10 @@ static LC_MSGCOMP undelete_id;
void
CmdMsgInit
(
DDD
::
DDDContext
&
context
)
{
cmdmsg_t
=
LC_NewMsgType
(
context
,
"CmdMsg"
);
undelete_id
=
LC_NewMsgTable
(
"UndelTab"
,
cmdmsg_t
,
sizeof
(
DDD_GID
));
auto
&
ctx
=
context
.
cmdmsgContext
();
ctx
.
cmdmsg_t
=
LC_NewMsgType
(
context
,
"CmdMsg"
);
ctx
.
undelete_id
=
LC_NewMsgTable
(
"UndelTab"
,
ctx
.
cmdmsg_t
,
sizeof
(
DDD_GID
));
}
...
...
@@ -136,6 +123,8 @@ static CMDMSG *CreateCmdMsg (DDD_PROC dest, CMDMSG *lastxm)
static
int
PrepareCmdMsgs
(
DDD
::
DDDContext
&
context
,
XICopyObj
**
itemsCO
,
int
nCO
,
CMDMSG
**
theMsgs
)
{
auto
&
ctx
=
context
.
cmdmsgContext
();
CMDMSG
*
xm
=
NULL
;
int
j
,
iCO
,
markedCO
,
nMsgs
=
0
;
DDD_GID
*
gids
;
...
...
@@ -231,15 +220,15 @@ static int PrepareCmdMsgs (DDD::DDDContext& context, XICopyObj **itemsCO, int nC
DDD_GID
*
array
;
/* create new send message */
xm
->
msg_h
=
LC_NewSendMsg
(
context
,
cmdmsg_t
,
xm
->
proc
);
xm
->
msg_h
=
LC_NewSendMsg
(
context
,
ctx
.
cmdmsg_t
,
xm
->
proc
);
/* init tables inside message */
LC_SetTableSize
(
xm
->
msg_h
,
undelete_id
,
xm
->
nUnDelete
);
LC_SetTableSize
(
xm
->
msg_h
,
ctx
.
undelete_id
,
xm
->
nUnDelete
);
/* prepare message for sending away */
LC_MsgPrepareSend
(
context
,
xm
->
msg_h
);
array
=
(
DDD_GID
*
)
LC_GetPtr
(
xm
->
msg_h
,
undelete_id
);
array
=
(
DDD_GID
*
)
LC_GetPtr
(
xm
->
msg_h
,
ctx
.
undelete_id
);
memcpy
((
char
*
)
array
,
(
char
*
)
xm
->
aUnDelete
,
sizeof
(
DDD_GID
)
*
xm
->
nUnDelete
);
...
...
@@ -272,13 +261,15 @@ static int CmdMsgUnpack (DDD::DDDContext& context,
LC_MSGHANDLE
*
theMsgs
,
int
nRecvMsgs
,
XIDelCmd
**
itemsDC
,
int
nDC
)
{
auto
&
ctx
=
context
.
cmdmsgContext
();
int
i
,
k
,
jDC
,
iDC
,
pos
,
nPruned
;
int
lenGidTab
=
0
;
for
(
i
=
0
;
i
<
nRecvMsgs
;
i
++
)
{
LC_MSGHANDLE
xm
=
theMsgs
[
i
];
lenGidTab
+=
(
int
)
LC_GetTableLen
(
xm
,
undelete_id
);
lenGidTab
+=
(
int
)
LC_GetTableLen
(
xm
,
ctx
.
undelete_id
);
}
if
(
lenGidTab
==
0
)
...
...
@@ -289,12 +280,12 @@ static int CmdMsgUnpack (DDD::DDDContext& context,
for
(
i
=
0
,
pos
=
0
;
i
<
nRecvMsgs
;
i
++
)
{
LC_MSGHANDLE
xm
=
theMsgs
[
i
];
int
len
=
LC_GetTableLen
(
xm
,
undelete_id
);
int
len
=
LC_GetTableLen
(
xm
,
ctx
.
undelete_id
);
if
(
len
>
0
)
{
memcpy
((
char
*
)
(
unionGidTab
.
data
()
+
pos
),
(
char
*
)
LC_GetPtr
(
xm
,
undelete_id
),
(
char
*
)
LC_GetPtr
(
xm
,
ctx
.
undelete_id
),
sizeof
(
DDD_GID
)
*
len
);
pos
+=
len
;
}
...
...
@@ -388,22 +379,24 @@ static int CmdMsgUnpack (DDD::DDDContext& context,
/****************************************************************************/
static
void
CmdMsgDisplay
(
const
char
*
comment
,
LC_MSGHANDLE
xm
)
static
void
CmdMsgDisplay
(
DDD
::
DDDContext
&
context
,
const
char
*
comment
,
LC_MSGHANDLE
xm
)
{
auto
&
ctx
=
context
.
cmdmsgContext
();
using
std
::
setw
;
std
::
ostream
&
out
=
std
::
cout
;
DDD_GID
*
theGid
;
char
buf
[
30
];
int
proc
=
LC_MsgGetProc
(
xm
);
int
lenGid
=
(
int
)
LC_GetTableLen
(
xm
,
undelete_id
);
int
lenGid
=
(
int
)
LC_GetTableLen
(
xm
,
ctx
.
undelete_id
);
std
::
ostringstream
prefixStream
;
prefixStream
<<
setw
(
3
)
<<
me
<<
"-"
<<
comment
<<
setw
(
3
)
<<
proc
<<
" "
;
const
std
::
string
&
prefix
=
prefixStream
.
str
();
/* get table addresses inside message */
theGid
=
(
DDD_GID
*
)
LC_GetPtr
(
xm
,
undelete_id
);
theGid
=
(
DDD_GID
*
)
LC_GetPtr
(
xm
,
ctx
.
undelete_id
);
out
<<
prefix
<<
" 04 Gid.size="
<<
setw
(
5
)
<<
lenGid
<<
"
\n
"
;
...
...
@@ -434,6 +427,8 @@ int PruneXIDelCmd (
XIDelCmd
**
itemsDC
,
int
nDC
,
std
::
vector
<
XICopyObj
*>&
arrayCO
)
{
auto
&
ctx
=
context
.
cmdmsgContext
();
CMDMSG
*
sendMsgs
,
*
sm
=
0
;
LC_MSGHANDLE
*
recvMsgs
;
int
nSendMsgs
,
nRecvMsgs
;
...
...
@@ -451,12 +446,12 @@ int PruneXIDelCmd (
{
for
(
sm
=
sendMsgs
;
sm
!=
NULL
;
sm
=
sm
->
next
)
{
CmdMsgDisplay
(
"PS"
,
sm
->
msg_h
);
CmdMsgDisplay
(
context
,
"PS"
,
sm
->
msg_h
);
}
}
/* init communication topology */
nRecvMsgs
=
LC_Connect
(
context
,
cmdmsg_t
);
nRecvMsgs
=
LC_Connect
(
context
,
ctx
.
cmdmsg_t
);
/* build and send messages */
CmdMsgSend
(
context
,
sendMsgs
);
...
...
@@ -474,7 +469,7 @@ int PruneXIDelCmd (
#if DebugCmdMsg>=2
if (DDD_GetOption(context, OPT_DEBUG_XFERMESGS)==OPT_ON)
#endif
CmdMsgDisplay("PR", recvMsgs[i]);
CmdMsgDisplay(
context,
"PR", recvMsgs[i]);
}
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment