-
Notifications
You must be signed in to change notification settings - Fork 16
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
Feature/sidre data collection #64
Conversation
…e or tested. project compiles
methods -- simplest way of dealing with templated methods like this.
…ikeowen/spheral into feature/sidre-data-collection
CXXTest Build Fix
From the build dir make test should work |
src/CXXTests/testSidreStorage.cc
Outdated
} | ||
}; | ||
|
||
using MyTypes = ::testing::Types<char, int, size_t, uint32_t, uint64_t, float, double>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this type alias to something more descriptive
src/CXXTests/testSidreStorage.cc
Outdated
template <typename T> | ||
class SidreDataCollectionTest : public ::testing::Test | ||
{ | ||
public: | ||
Spheral::SidreDataCollection myData; | ||
int n = 100; | ||
T* rawSidreData; | ||
|
||
Spheral::Field<Spheral::Dim<1>, T> makeField() | ||
{ | ||
Spheral::NodeList<Spheral::Dim<1>> makeNodeList("test bed", n, 0); | ||
Spheral::Field<Spheral::Dim<1>, T> testField("test field", makeNodeList); | ||
for (int i = 0; i < n; i++) | ||
testField[i] = i; | ||
return testField; | ||
} | ||
|
||
void allocRawSidreData(const Spheral::Field<Spheral::Dim<1>, T>& testField) | ||
{ | ||
rawSidreData = myData.alloc_view("SidreTest", testField)->getData(); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move all helper classes, functions, includes and type aliases into a separate header file keeping only the gtest "TEST" type calls in this file.
src/Field/Field.hh
Outdated
@@ -235,6 +236,10 @@ public: | |||
std::vector<DataType> ghostValues() const; | |||
std::vector<DataType> allValues() const; | |||
|
|||
// Functions to help with storing the field in a Sidre datastore. | |||
axom::sidre::DataTypeId getAxomType() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to getAxomTypeID, I thought you were trying to return an actual type here at first instead of the axom ID.
src/CXXTests/CMakeLists.txt
Outdated
foreach(test ${gtest_spheral_tests}) | ||
get_filename_component( test_name ${test} NAME_WE ) | ||
blt_add_executable( NAME ${test_name}_test | ||
blt_add_executable( NAME ${test_name}_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump
In src/Utilities/SidreDataCollection, wouldn't it be preferable to use a std::shared_ptraxom::sidre::DataStore rather than a bare C pointer? This way you can construct using std::make_shared, and not worry about deallocating in the destructor. In general I try to avoid using bare pointers with new/delete just to avoid memory confusion down the line. |
Sidre data collection test re-org
class SidreDataCollection | ||
{ | ||
public: | ||
SidreDataCollection() {}; | ||
~SidreDataCollection() {}; | ||
|
||
template <typename Dimension, typename DataType, | ||
typename std::enable_if<std::is_arithmetic<DataType>::value, | ||
DataType>::type* = nullptr> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, DataType> &field); | ||
|
||
template <typename Dimension, typename DataType, | ||
typename std::enable_if<is_rank_n_tensor<DataType>::value && !std::is_arithmetic<DataType>::value, | ||
DataType>::type* = nullptr> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, DataType> &field); | ||
|
||
template <typename Dimension, typename DataType, | ||
typename std::enable_if<!is_rank_n_tensor<DataType>::value && !std::is_arithmetic<DataType>::value, | ||
DataType>::type* = nullptr> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, DataType> &field); | ||
|
||
|
||
template<typename Dimension> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, std::string> &field); | ||
template<typename Dimension, typename DataType> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, std::vector<DataType>> &field); | ||
template<typename Dimension, typename DataType> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, std::tuple<DataType, DataType, DataType>> &field); | ||
template<typename Dimension, typename DataType> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, std::tuple<DataType, DataType, DataType, DataType>> &field); | ||
template<typename Dimension, typename DataType> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, std::tuple<DataType, DataType, DataType, DataType, DataType>> &field); | ||
template<typename Dimension> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, Dim<2>::Vector> &field); | ||
|
||
|
||
private: | ||
std::shared_ptr<axom::sidre::DataStore> m_datastore_ptr = std::make_shared<axom::sidre::DataStore>(); | ||
}; | ||
|
||
} // namespace Spheral |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this class declaration duplicated here?
axom::sidre::Group *SidreDataCollection::sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, std::string> &field) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting across this file
src/Utilities/SidreDataCollection.hh
Outdated
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, DataType> &field); | ||
|
||
template <typename Dimension, typename DataType, | ||
typename std::enable_if<is_rank_n_tensor<DataType>::value && !std::is_arithmetic<DataType>::value, | ||
DataType>::type* = nullptr> | ||
axom::sidre::Group *sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, DataType> &field); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
axom::sidre::Group *SidreDataCollection::sidreStoreField(const std::string &view_name, | ||
const Spheral::Field<Dimension, std::tuple<DataType, DataType, DataType, DataType, DataType>> &field) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters are lined up, but the second one is very long. Do I need break it up onto more lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the prettiest, if you can break it up into a format that maintains the readability go for it, but I don't think it's too much of an issue, this only really effects the tuple cases.
@jmikeowen I think we might have the "make test" ats test added in a separate PR as that is going to require us to do some build system trickery to encode the build directory path into the python test file and I'd like to talk about some ideas. @MishaZakharchanka Please fix the formatting in src/CXXTests/CMakeLists.txt. After that I'll be happy to approve this PR. |
Sure, we can talk about how to add the CXX tests. I'm gonna be traveling
until next week, but we can do this sometime then.
…On Fri, Aug 13, 2021 at 3:06 PM Michael Davis ***@***.***> wrote:
@jmikeowen <https://github.com/jmikeowen> I think we might have the "make
test" ats test added in a separate PR as that is going to require us to do
some build system trickery to encode the build directory path into the
python test file and I'd like to talk about some ideas.
@MishaZakharchanka <https://github.com/MishaZakharchanka> Please fix the
formatting in src/CXXTests/CMakeLists.txt. After that I'll be happy to
approve this PR.
LGTM 👍
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#64 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCN6BXWD2HPLF4NIS3QGX3T4WCM3ANCNFSM43IZBB5A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
As of now this branch is up to date with develop, so we should be good to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to go.
Adding functions to store DataTypes into sidre and tests for the those functions.