Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
6b691f17
Commit
6b691f17
authored
Aug 11, 2009
by
mattijs
Browse files
provision for non-blocking comms
parent
5897f931
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C
View file @
6b691f17
...
...
@@ -78,7 +78,15 @@ inline void Foam::IPstream::readFromBuffer
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam
::
IPstream
::~
IPstream
()
{}
{
if
(
bufPosition_
<
messageSize_
)
{
FatalErrorIn
(
"IPstream::~IPstream()"
)
<<
"Message not fully consumed. messageSize:"
<<
messageSize_
<<
" bytes of which only "
<<
bufPosition_
<<
" consumed."
<<
Foam
::
abort
(
FatalError
);
}
}
...
...
src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H
View file @
6b691f17
...
...
@@ -350,6 +350,31 @@ public:
return
oldCommsType
;
}
//- Transfer buffer
const
List
<
char
>&
buf
()
const
{
return
buf_
;
}
//- Transfer buffer
List
<
char
>&
buf
()
{
return
buf_
;
}
//- Current buffer read/write location
int
bufPosition
()
const
{
return
bufPosition_
;
}
//- Current buffer read/write location
int
&
bufPosition
()
{
return
bufPosition_
;
}
//- Exit program
static
void
exit
(
int
errnum
=
1
);
...
...
src/Pstream/mpi/IPread.C
View file @
6b691f17
...
...
@@ -61,24 +61,38 @@ Foam::IPstream::IPstream
MPI_Status
status
;
// Cannot use buf_.size() since appends a few bytes extra
label
realBufSize
=
bufSize
;
// If the buffer size is not specified, probe the incomming message
// and set it
if
(
!
bufSize
)
{
if
(
commsType
==
nonBlocking
)
{
FatalErrorIn
(
"IPstream::IPstream(const commsTypes, const int, "
"const label, streamFormat, versionNumber)"
)
<<
"Can use nonBlocking mode only with pre-allocated buffers"
<<
Foam
::
abort
(
FatalError
);
}
MPI_Probe
(
procID
(
fromProcNo_
),
msgType
(),
MPI_COMM_WORLD
,
&
status
);
MPI_Get_count
(
&
status
,
MPI_BYTE
,
&
messageSize_
);
buf_
.
setSize
(
messageSize_
);
realBufSize
=
buf_
.
size
();
}
messageSize_
=
read
(
commsType
,
fromProcNo_
,
buf_
.
begin
(),
buf_
.
s
ize
()
);
messageSize_
=
read
(
commsType
,
fromProcNo_
,
buf_
.
begin
(),
realBufS
ize
);
if
(
!
messageSize_
)
{
FatalErrorIn
(
"IPstream::IPstream(const
int fromProcNo
, "
"const label
bufSize
, streamFormat
format
, versionNumber
version
)"
"IPstream::IPstream(const
commsTypes, const int
, "
"const label, streamFormat, versionNumber)"
)
<<
"read failed"
<<
Foam
::
abort
(
FatalError
);
}
...
...
@@ -173,7 +187,8 @@ Foam::label Foam::IPstream::read
IPstream_outstandingRequests_
.
append
(
request
);
return
1
;
// Assume the message is completely received.
return
bufSize
;
}
else
{
...
...
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