Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PABLO: fix markers communication #26

Merged
merged 53 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
90b9695
patchkernel: allow to squeeze storage of skd-tree after its generation
edoardolombardi Oct 18, 2019
30e3add
patchkernel: update initial reserve size for the skd-tree
edoardolombardi Oct 18, 2019
3cb4de3
IO/STL: use a style consistent with bitpit syle guide
andrea-iob Sep 22, 2019
4dc587d
IO/STL: make utility functions private functions of 'STLObj' object
andrea-iob Sep 22, 2019
0831d75
IO/STL: appending data to an existing file is only supported for ASCI…
andrea-iob Sep 25, 2019
008b4f6
IO/STL: use propery size constant when reading the number of facets
andrea-iob Sep 29, 2019
75cf9bc
IO/STL: use the term facet consistently
andrea-iob Oct 1, 2019
ea497e9
IO/STL: define common constants as class members
andrea-iob Oct 1, 2019
e046f01
IO/STL: cosmetic fixes to Doxygen documentation
andrea-iob Oct 1, 2019
e1f0349
IO/STL: properly include header file of module "operators"
andrea-iob Sep 25, 2019
18abd0c
IO/STL: rename functions and members related to STL format
andrea-iob Oct 2, 2019
a7a98df
IO/STL: use bigger integers to store data related to vertices and tri…
andrea-iob Oct 2, 2019
528e62e
IO/STL: add a base class for STL objects
andrea-iob Oct 2, 2019
07606eb
IO/STL: add STLReader and STLWriter classes
andrea-iob Oct 2, 2019
185c9e4
test/IO: test STL binary/ASCII detection using the STLReader class
andrea-iob Oct 2, 2019
9f57675
surfunstructured: cosmetic fixes
andrea-iob Oct 2, 2019
9c28b2f
surfunstructured: make I/O routines return integer error codes
andrea-iob Oct 2, 2019
a33ab5b
surfunstructured: add argument names to function prototypes
andrea-iob Oct 2, 2019
3c3d592
surfunstructured: avoid passing constant references to bool values
andrea-iob Oct 2, 2019
84032eb
test/surfunstructured: update checks on return value of importSTL/exp…
andrea-iob Oct 2, 2019
c4aba14
surfunstructured: import STL files using the STLReader class
andrea-iob Oct 2, 2019
c260ee3
surfunstructured: export STL files using the STLWriter class
andrea-iob Oct 2, 2019
444d51b
IO/STL: remove STLObj class and STLData struct
andrea-iob Oct 2, 2019
491cdd0
IO/STL: drop overloads that take as arguments vectors of vectors
andrea-iob Oct 4, 2019
dc3fe43
IO/STL: simplify writing of ASCII files
andrea-iob Oct 4, 2019
61ae287
IO/STL: add support for writing an STL one facet at a time
andrea-iob Oct 4, 2019
edc6a8b
IO/STL: add support for reading an STL one facet at a time
andrea-iob Oct 6, 2019
fe1099a
IO/STL: avoid using std::endl
andrea-iob Oct 6, 2019
d096a63
test/surfunstructured: fix STL data file
andrea-iob Oct 6, 2019
8e3ab4a
surfunstructured: rename some variables
andrea-iob Oct 5, 2019
0454a2d
surfunstructured: rework STL export
andrea-iob Oct 5, 2019
4979f6a
surfunstructured: rework STL import
andrea-iob Oct 6, 2019
0da2816
surfunstructured: remove unneeded function
andrea-iob Oct 7, 2019
b9ef4db
IO/STL: set stream properties when opening the file
andrea-iob Oct 6, 2019
a9845d6
IO/STL: allow ASCII STL files with end-solid tag not matching the sol…
andrea-iob Oct 21, 2019
2b8b5a0
test/surfunstructured: add output message at the end of the sub-test
andrea-iob Oct 6, 2019
4119c6a
patchkernel: update Doxygen documentation for the PatchSkdTree class
andrea-iob Oct 19, 2019
5190770
patchkernel: use proper functions to get skd-tree nodes
andrea-iob Oct 19, 2019
167a647
patchkernel: add comments
andrea-iob Oct 19, 2019
00ca420
patchkernel: add infrastructure for building skd-trees with variable
andrea-iob Oct 18, 2019
44b665e
patchkernel: allow creating skd-trees of patches with coincident cells
andrea-iob Oct 19, 2019
71b277a
containers: use std::size_t to define the size of FlatVector2D sub-ar…
andrea-iob Sep 16, 2019
e6a16e6
containers: use memcpy when writing data into the binary stream
andrea-iob Oct 17, 2019
090c966
containers: remove unneded reinterpret cast
andrea-iob Oct 17, 2019
ca83311
containers: remove binary stream read/write templates
andrea-iob Oct 17, 2019
f464994
containers: add template specializations to read/write vectors from/t…
andrea-iob Nov 20, 2019
c8e5e75
containers: declare read/write functions of binary stream as public
andrea-iob Oct 17, 2019
15f4b0f
containers: fix Doxygen documentation
andrea-iob Oct 17, 2019
d36388d
communications: add read/write functions to communication buffers
andrea-iob Oct 17, 2019
ebcfef2
containers: optimize streaming of FlatVector2D to/from binary stream
andrea-iob Oct 17, 2019
9ee216d
patchkernel: optimize streaming of vertex to/from binary stream
andrea-iob Oct 17, 2019
3436e87
patchkernel: optimize streaming of element to/from binary stream
andrea-iob Oct 17, 2019
bae204e
PABLO: fix marker communicator sendBuffer filling
marcocisternino Dec 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,143 changes: 1,441 additions & 2,702 deletions src/IO/STL.cpp

Large diffs are not rendered by default.

531 changes: 160 additions & 371 deletions src/IO/STL.hpp

Large diffs are not rendered by default.

395 changes: 0 additions & 395 deletions src/IO/STL.tpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/PABLO/ParaTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6008,7 +6008,7 @@ namespace bitpit {
std::size_t buffSize = nRankBorders * MARKER_ENTRY_BINARY_SIZE;
markerCommunicator.setSend(rank, buffSize);

SendBuffer sendBuffer = markerCommunicator.getSendBuffer(rank);
SendBuffer &sendBuffer = markerCommunicator.getSendBuffer(rank);
for(std::size_t i = 0; i < nRankBorders; ++i){
const Octant &octant = m_octree.m_octants[rankBordersPerProc[i]];
sendBuffer << octant.getMarker();
Expand Down
24 changes: 24 additions & 0 deletions src/communications/communications_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ void SendBuffer::squeeze()
}
}

/*!
* Write data into the buffer.
*
* \param[in] data is the memory that contain the data
* \param[in] size is the size (in bytes) of the data to be written into
* the stream
*/
void SendBuffer::write(const char *data, std::size_t size)
{
getFront().write(data, size);
}

/*!
\class RecvBuffer
\ingroup communications
Expand All @@ -67,4 +79,16 @@ RecvBuffer::RecvBuffer(size_t size, bool doubleBuffer)
{
}

/*!
* Read data from the buffer.
*
* \param[out] data is the memory location that will contain the data
* \param[in] size is the size (in bytes) of the data to be read from the
* stream
*/
void RecvBuffer::read(char *data, std::size_t size)
{
getFront().read(data, size);
}

}
4 changes: 4 additions & 0 deletions src/communications/communications_buffers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class SendBuffer : public CommunicationBuffer<RawSendBuffer>

void squeeze();

void write(const char *data, std::size_t size);

};

class RecvBuffer : public CommunicationBuffer<RawRecvBuffer>
Expand All @@ -111,6 +113,8 @@ class RecvBuffer : public CommunicationBuffer<RawRecvBuffer>
public:
RecvBuffer(size_t size = 0, bool doubleBuffer = false);

void read(char *data, std::size_t size);

};

}
Expand Down
15 changes: 6 additions & 9 deletions src/containers/binary_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ template<>
bitpit::IBinaryStream& operator>>(bitpit::IBinaryStream &stream, std::string &value)
{
int size = 0;
stream.read(size);
stream.read(reinterpret_cast<char *>(&size), sizeof(size));

if (size > 0) {
std::vector<char> buffer(size);
stream.read(buffer);
stream.read(buffer.data(), size);
value.assign(buffer.data(), size);
}

Expand All @@ -59,7 +59,7 @@ template<>
bitpit::OBinaryStream& operator<<(bitpit::OBinaryStream &stream, const std::string &value)
{
int size = value.size();
stream.write(size);
stream.write(reinterpret_cast<const char *>(&size), sizeof(size));

if (size > 0) {
stream.write(value.c_str(), size);
Expand All @@ -68,7 +68,6 @@ bitpit::OBinaryStream& operator<<(bitpit::OBinaryStream &stream, const std::stri
return stream;
}


namespace bitpit {

/*!
Expand Down Expand Up @@ -423,7 +422,7 @@ void IBinaryStream::read(char *data, std::size_t size)
throw std::runtime_error("Bad memory access!");
}

std::memcpy(reinterpret_cast<void*>(data), m_buffer.data() + m_pos, size);
std::memcpy(data, m_buffer.data() + m_pos, size);
m_pos += size;
}

Expand Down Expand Up @@ -529,10 +528,8 @@ void OBinaryStream::write(const char *data, std::size_t size)
setSize(bufferSize);
}

for (std::size_t i = 0; i < size; ++i) {
m_buffer[m_pos] = data[i];
++m_pos;
}
std::memcpy(m_buffer.data() + m_pos, data, size);
m_pos += size;
}

}
14 changes: 8 additions & 6 deletions src/containers/binary_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ class OBinaryStream;
template<typename T>
bitpit::IBinaryStream & operator>>(bitpit::IBinaryStream &stream, T &value);

template<typename T>
bitpit::IBinaryStream& operator>>(bitpit::IBinaryStream &stream, std::vector<T> &vector);

template<>
bitpit::IBinaryStream & operator>>(bitpit::IBinaryStream &stream, std::string &value);

template<typename T>
bitpit::OBinaryStream & operator<<(bitpit::OBinaryStream &stream, const T &value);

template<typename T>
bitpit::OBinaryStream& operator<<(bitpit::OBinaryStream &stream, const std::vector<T> &vector);

template<>
bitpit::OBinaryStream & operator<<(bitpit::OBinaryStream &stream, const std::string &value);

Expand Down Expand Up @@ -112,9 +118,6 @@ friend IBinaryStream & (::operator>>)(IBinaryStream &stream, T &value);
void open(const char *buffer, std::size_t size);
void open(std::size_t size);

private:
template<typename T>
void read(T &value);
void read(char *data, std::size_t size);

};
Expand All @@ -133,12 +136,11 @@ friend OBinaryStream & (::operator<<)(OBinaryStream &stream, const T &value);
void setSize(std::size_t size) override;
void squeeze();

void write(const char *data, std::size_t size);

private:
bool m_expandable;

template<typename T>
void write(const T &value);
void write(const char *data, std::size_t size);
};

}
Expand Down
54 changes: 35 additions & 19 deletions src/containers/binary_stream.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
\*---------------------------------------------------------------------------*/

/*!
* Write the specified value into the stream.
* Read the specified value from the stream.
*
* \param[in] stream is the input stream
* \param[in] value is the value to be streamed
Expand All @@ -32,48 +32,64 @@
template<typename T>
bitpit::IBinaryStream& operator>>(bitpit::IBinaryStream &stream, T &value)
{
stream.read(value);
stream.read(reinterpret_cast<char *>(&value), sizeof(T));

return stream;
}

/*!
* Write the specified value into the stream.
* Read the specified vector from the stream.
*
* \param[in] stream is the output stream
* \param[in] value is the value to be streamed
* \result Returns the updated output stream.
* Input vector will be resized to match the size of the vector stored in the
* stream.
*
* \param[in] stream is the input stream
* \param[in] vector is the vector to be streamed
* \result Returns the updated input stream.
*/
template<typename T>
bitpit::OBinaryStream& operator<<(bitpit::OBinaryStream &stream, const T &value)
bitpit::IBinaryStream& operator>>(bitpit::IBinaryStream &stream, std::vector<T> &vector)
{
stream.write(value);
std::size_t size;
stream.read(reinterpret_cast<char *>(&size), sizeof(size));
vector.resize(size);

stream.read(reinterpret_cast<char *>(vector.data()), size * sizeof(T));

return stream;
}

namespace bitpit {

/*!
* Read the specified value from the stream.
* Write the specified value into the stream.
*
* \param[in] value is the value that will be read
* \param[in] stream is the output stream
* \param[in] value is the value to be streamed
* \result Returns the updated output stream.
*/
template<typename T>
void IBinaryStream::read(T &value)
bitpit::OBinaryStream& operator<<(bitpit::OBinaryStream &stream, const T &value)
{
read(reinterpret_cast<char *>(&value), sizeof(T));
stream.write(reinterpret_cast<const char *>(&value), sizeof(T));

return stream;
}

/*!
* Write the specified value into the stream.
* Write the specified vector into the stream.
*
* Along with vector data, also the size of the vector is stored into the
* stream.
*
* \param[in] value is the value that will be written
* \param[in] vector is the vector to be streamed
* \result Returns the updated output stream.
*/
template<typename T>
void OBinaryStream::write(const T &value)
bitpit::OBinaryStream& operator<<(bitpit::OBinaryStream &stream, const std::vector<T> &vector)
{
write(reinterpret_cast<const char *>(&value), sizeof(T));
}
std::size_t size = vector.size();
stream.write(reinterpret_cast<const char *>(&size), sizeof(size));

stream.write(reinterpret_cast<const char *>(vector.data()), size * sizeof(T));

return stream;
}
59 changes: 30 additions & 29 deletions src/containers/flatVector2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ friend bitpit::IBinaryStream& (::operator>>) (bitpit::IBinaryStream &buffer, Fla

public:
FlatVector2D(bool initialize = true);
FlatVector2D(const std::vector<int> &sizes, const T &value = T());
FlatVector2D(int nVectors, int size, const T &value = T());
FlatVector2D(const std::vector<std::size_t> &sizes, const T &value = T());
FlatVector2D(std::size_t nVectors, std::size_t size, const T &value = T());
FlatVector2D(const std::vector<std::vector<T> > &vector2D);
FlatVector2D(const FlatVector2D &other) = default;
FlatVector2D(FlatVector2D &&other) = default;
Expand All @@ -91,12 +91,13 @@ friend bitpit::IBinaryStream& (::operator>>) (bitpit::IBinaryStream &buffer, Fla
FlatVector2D & operator=(FlatVector2D &&other) = default;

void initialize(const std::vector<int> &sizes, const T &value = T());
void initialize(int nVectors, int size, const T &value = T());
void initialize(const std::vector<std::size_t> &sizes, const T &value = T());
void initialize(std::size_t nVectors, std::size_t size, const T &value = T());
void initialize(const std::vector<std::vector<T> > &vector2D);
void initialize(const FlatVector2D<T> &other);

void destroy();
void reserve(int nVectors, int nItems = 0);
void reserve(std::size_t nVectors, std::size_t nItems = 0);
void swap(FlatVector2D &other) noexcept;
bool operator==(const FlatVector2D& rhs) const;
void fill(T &value);
Expand All @@ -107,58 +108,58 @@ friend bitpit::IBinaryStream& (::operator>>) (bitpit::IBinaryStream &buffer, Fla
void shrinkToFit();

const std::size_t * indices() const noexcept;
const std::size_t * indices(int i) const noexcept;
const std::size_t * indices(std::size_t i) const noexcept;

T * data() noexcept;
const T * data() const noexcept;
const std::vector<T> & vector() const;

void pushBack();
void pushBack(int subArraySize, const T &value = T());
void pushBack(std::size_t subArraySize, const T &value = T());
void pushBack(const std::vector<T> &subArray);
void pushBack(int subArraySize, const T *subArray);
void pushBack(std::size_t subArraySize, const T *subArray);
void pushBackItem(const T& value);
void pushBackItem(int i, const T& value);
void pushBackItem(std::size_t i, const T& value);

void popBack();
void popBackItem();
void popBackItem(int i);
void popBackItem(std::size_t i);

void erase(int i);
void eraseItem(int i, int j);
void erase(std::size_t i);
void eraseItem(std::size_t i, std::size_t j);

void setItem(int i, int j, const T &value);
T & getItem(int i, int j);
const T & getItem(int i, int j) const;
const T * get(int i) const;
T * get(int i);
void setItem(std::size_t i, std::size_t j, const T &value);
T & getItem(std::size_t i, std::size_t j);
const T & getItem(std::size_t i, std::size_t j) const;
const T * get(std::size_t i) const;
T * get(std::size_t i);

void rawSetItem(int k, const T &value);
T & rawGetItem(int k);
const T & rawGetItem(int k) const;
void rawSetItem(std::size_t k, const T &value);
T & rawGetItem(std::size_t k);
const T & rawGetItem(std::size_t k) const;

T * back();
T * first();

int size() const;
int capacity() const;
std::size_t size() const;
std::size_t capacity() const;

void merge();

int getItemCount() const;
int getItemCount(int i) const;
int getItemCapacity() const;
std::size_t getItemCount() const;
std::size_t getItemCount(std::size_t i) const;
std::size_t getItemCapacity() const;

size_t getBinarySize() const;
std::size_t getBinarySize() const;

private:
std::vector<T> m_v;
std::vector<std::size_t> m_index;

const T* operator[](int i) const;
T* operator[](int i);
bool isIndexValid(int i) const;
bool isIndexValid(int i, int j) const;
const T* operator[](std::size_t i) const;
T* operator[](std::size_t i);
bool isIndexValid(std::size_t i) const;
bool isIndexValid(std::size_t i, std::size_t j) const;

void destroy(bool destroyIndex, bool destroyValues);

Expand Down
Loading