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

Feature/sidre data collection #64

Merged
merged 52 commits into from
Sep 8, 2021

Conversation

MishaZakharchanka
Copy link
Contributor

Adding functions to store DataTypes into sidre and tests for the those functions.

Mikhail Zakharchanka and others added 30 commits August 28, 2020 17:41
methods -- simplest way of dealing with templated methods like this.
@mdavis36
Copy link
Collaborator

So if I want to exercise the tests of the new stuff, what do I do? Does "make test" cover it?

From the build dir make test should work

}
};

using MyTypes = ::testing::Types<char, int, size_t, uint32_t, uint64_t, float, double>;
Copy link
Collaborator

@mdavis36 mdavis36 May 19, 2021

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

Comment on lines 9 to 30
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();
}
};
Copy link
Collaborator

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.

@@ -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;
Copy link
Collaborator

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/Utilities/SidreDataCollectionInline.hh Show resolved Hide resolved
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump

@jmikeowen
Copy link
Collaborator

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.

Comment on lines 17 to 66
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
Copy link
Collaborator

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?

Comment on lines 105 to 106
axom::sidre::Group *SidreDataCollection::sidreStoreField(const std::string &view_name,
const Spheral::Field<Dimension, std::string> &field)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting across this file

Comment on lines 26 to 33
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

Comment on lines +116 to +117
axom::sidre::Group *SidreDataCollection::sidreStoreField(const std::string &view_name,
const Spheral::Field<Dimension, std::tuple<DataType, DataType, DataType, DataType, DataType>> &field)
Copy link
Contributor Author

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?

Copy link
Collaborator

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.

@mdavis36
Copy link
Collaborator

@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.
LGTM 👍

@jmikeowen
Copy link
Collaborator

jmikeowen commented Aug 13, 2021 via email

@MishaZakharchanka
Copy link
Contributor Author

As of now this branch is up to date with develop, so we should be good to merge.

Copy link
Collaborator

@mdavis36 mdavis36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@jmikeowen jmikeowen left a 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.

@MishaZakharchanka MishaZakharchanka merged commit c53e13d into develop Sep 8, 2021
@MishaZakharchanka MishaZakharchanka deleted the feature/sidre-data-collection branch September 14, 2021 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants