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

ENH: Modify header files to decrease compiler time. #1064

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ set(SIMPLNX_HDRS
${SIMPLNX_SOURCE_DIR}/Utilities/ClusteringUtilities.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/MontageUtilities.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/SIMPLConversion.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/DataTypeUtilities.hpp

${SIMPLNX_SOURCE_DIR}/Utilities/Math/GeometryMath.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/Math/MatrixMath.hpp
Expand Down Expand Up @@ -720,6 +721,7 @@ set(SIMPLNX_SRCS
${SIMPLNX_SOURCE_DIR}/Utilities/SampleSurfaceMesh.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/MontageUtilities.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/TimeUtilities.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/DataTypeUtilities.cpp

${SIMPLNX_SOURCE_DIR}/Utilities/Parsing/DREAM3D/Dream3dIO.cpp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
#include "simplnx/Parameters/DataObjectNameParameter.hpp"
#include "simplnx/Parameters/GeometrySelectionParameter.hpp"
#include "simplnx/Parameters/NumberParameter.hpp"
// #define SIMPL_PARAM_CONVERT_CREATE_COLOR_MAP
// #define SIMPL_PARAM_CONVERT_ARRAY_THRESHOLD
// #define SIMPL_PARAM_CONVERT_DYNAMIC_TABLE
// #define SIMPL_PARAM_CONVERT_READ_CSV
// #define SIMPL_PARAM_CONVERT_READ_HDF5_DATASET
#include "simplnx/Utilities/SIMPLConversion.hpp"

#include <itkCastImageFilter.h>
#include <itkMaskImageFilter.h>

#include <numeric>

#include "simplnx/Utilities/SIMPLConversion.hpp"

#include <stdexcept>

using namespace nx::core;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
histogram[m_NumBins - 1]++;
}
} // end of numTuples loop
} // end of increment else
} // end of increment else

Check failure on line 274 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]

if(m_ModalBinRanges)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#include "simplnx/Parameters/FileSystemPathParameter.hpp"
#include "simplnx/Parameters/GeometrySelectionParameter.hpp"
#include "simplnx/Utilities/FilterUtilities.hpp"

// #define SIMPL_PARAM_CONVERT_CREATE_COLOR_MAP
// #define SIMPL_PARAM_CONVERT_ARRAY_THRESHOLD
// #define SIMPL_PARAM_CONVERT_DYNAMIC_TABLE
// #define SIMPL_PARAM_CONVERT_READ_CSV
// #define SIMPL_PARAM_CONVERT_READ_HDF5_DATASET
#include "simplnx/Utilities/SIMPLConversion.hpp"

#include <filesystem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
#include "simplnx/Filter/Actions/CreateArrayAction.hpp"
#include "simplnx/Parameters/ArraySelectionParameter.hpp"
#include "simplnx/Parameters/BoolParameter.hpp"
#include "simplnx/Parameters/CreateColorMapParameter.hpp"
#include "simplnx/Parameters/DataObjectNameParameter.hpp"

#include "simplnx/Parameters/VectorParameter.hpp"
#include "simplnx/Utilities/ColorTableUtilities.hpp"
#define SIMPL_PARAM_CONVERT_CREATE_COLOR_MAP
#include "simplnx/Utilities/SIMPLConversion.hpp"

#include "simplnx/Parameters/CreateColorMapParameter.hpp"
#include "simplnx/Parameters/VectorParameter.hpp"

using namespace nx::core;
namespace
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "simplnx/Parameters/NumberParameter.hpp"
#include "simplnx/Utilities/ArrayThreshold.hpp"
#include "simplnx/Utilities/FilterUtilities.hpp"
#define SIMPL_PARAM_CONVERT_ARRAY_THRESHOLD
#include "simplnx/Utilities/SIMPLConversion.hpp"

#include <algorithm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@ struct KDTreeEigenMatrixAdaptor
/** @} */

}; // end of KDTreeEigenMatrixAdaptor
/** @} */
/** @} */

/** @} */ // end of grouping
} // namespace nanoflann
Expand Down
15 changes: 5 additions & 10 deletions src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,7 @@
parameters.def("insert_linkable_parameter", &PyInsertLinkableParameter<ChoicesParameter>);
parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, BoolParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); });
parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, ChoicesParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); });
parameters.def(
"__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal);
parameters.def("__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal);

Check failure on line 587 in src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]

py::class_<IArrayThreshold, std::shared_ptr<IArrayThreshold>> iArrayThreshold(mod, "IArrayThreshold");

Expand Down Expand Up @@ -1422,12 +1421,10 @@
"path"_a);
pipeline.def_property("name", &Pipeline::getName, &Pipeline::setName);
pipeline.def("execute", &ExecutePipeline);
pipeline.def(
"__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal);
pipeline.def("__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal);

Check failure on line 1424 in src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]
pipeline.def("__len__", &Pipeline::size);
pipeline.def("size", &Pipeline::size);
pipeline.def(
"__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>());
pipeline.def("__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>());

Check failure on line 1427 in src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]
pipeline.def(
"insert",
[internals](Pipeline& self, Pipeline::index_type index, const IFilter& filter, const py::dict& args) {
Expand All @@ -1441,10 +1438,8 @@
pipeline.def("remove", &Pipeline::removeAt, "index"_a);

pipelineFilter.def("get_args", [internals](PipelineFilter& self) { return ConvertArgsToDict(*internals, self.getParameters(), self.getArguments()); });
pipelineFilter.def(
"set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a);
pipelineFilter.def(
"get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal);
pipelineFilter.def("set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a);

Check failure on line 1441 in src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]
pipelineFilter.def("get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal);

Check failure on line 1442 in src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]
pipelineFilter.def(
"name",
[](const PipelineFilter& self) {
Expand Down
22 changes: 0 additions & 22 deletions src/simplnx/Common/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,4 @@ enum class FaultState
Errors = 2
};

inline const std::set<DataType>& GetAllDataTypes()
{
static const std::set<DataType> dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16,
nx::core::DataType::int32, nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64,
nx::core::DataType::float32, nx::core::DataType::float64, nx::core::DataType::boolean};
return dataTypes;
}

inline const std::set<DataType>& GetAllNumericTypes()
{
static const std::set<DataType> dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16, nx::core::DataType::int32,
nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64, nx::core::DataType::float32, nx::core::DataType::float64};
return dataTypes;
}

inline const std::set<DataType>& GetIntegerDataTypes()
{
static const std::set<DataType> dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16,
nx::core::DataType::int32, nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64};
return dataTypes;
}

} // namespace nx::core
5 changes: 3 additions & 2 deletions src/simplnx/DataStructure/IO/Generic/DataIOCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ std::unique_ptr<IDataStore> DataIOCollection::createDataStore(const std::string&
return nullptr;
}

void DataIOCollection::checkStoreDataFormat(uint64 dataSize, std::string& dataFormat) const
std::string DataIOCollection::checkStoreDataFormat(uint64 dataSize, std::string dataFormat) const
{
if(!dataFormat.empty())
{
return;
return dataFormat;
}
const Preferences* preferences = Application::GetOrCreateInstance()->getPreferences();
const uint64 largeDataSize = preferences->valueAs<uint64>(Preferences::k_LargeDataSize_Key);
Expand All @@ -72,6 +72,7 @@ void DataIOCollection::checkStoreDataFormat(uint64 dataSize, std::string& dataFo
{
dataFormat = largeDataFormat;
}
return dataFormat;
}

std::vector<std::string> DataIOCollection::getFormatNames() const
Expand Down
7 changes: 3 additions & 4 deletions src/simplnx/DataStructure/IO/Generic/DataIOCollection.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#pragma once

#include "simplnx/DataStructure/AbstractDataStore.hpp"
#include "simplnx/simplnx_export.hpp"

#include "simplnx/Common/Types.hpp"
#include "simplnx/Common/TypesUtility.hpp"
#include "simplnx/DataStructure/AbstractDataStore.hpp"
#include "simplnx/simplnx_export.hpp"

#include <map>
#include <memory>
Expand Down Expand Up @@ -63,7 +62,7 @@ class SIMPLNX_EXPORT DataIOCollection
/**
* @brief Checks the
*/
void checkStoreDataFormat(uint64 dataSize, std::string& dataFormat) const;
std::string checkStoreDataFormat(uint64 dataSize, std::string dataFormat) const;

iterator begin();
iterator end();
Expand Down
2 changes: 1 addition & 1 deletion src/simplnx/Filter/FilterTraits.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "simplnx/Common/StringLiteral.hpp"
// #include "simplnx/Common/StringLiteral.hpp"
#include "simplnx/Filter/IFilter.hpp"

#include <type_traits>
Expand Down
3 changes: 2 additions & 1 deletion src/simplnx/Parameters/ArraySelectionParameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "simplnx/DataStructure/IArray.hpp"
#include "simplnx/Filter/MutableDataParameter.hpp"
#include "simplnx/Filter/ParameterTraits.hpp"
#include "simplnx/Utilities/DataTypeUtilities.hpp"
#include "simplnx/simplnx_export.hpp"

#include <set>
Expand All @@ -18,7 +19,7 @@ class SIMPLNX_EXPORT ArraySelectionParameter : public MutableDataParameter
{
public:
using ValueType = DataPath;
using AllowedTypes = std::set<DataType>;
using AllowedTypes = nx::core::DataTypeSetType;
using AllowedComponentShapes = std::vector<IArray::ShapeType>;

enum class DataLocation : uint8
Expand Down
3 changes: 2 additions & 1 deletion src/simplnx/Parameters/MultiArraySelectionParameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "simplnx/DataStructure/IArray.hpp"
#include "simplnx/Filter/MutableDataParameter.hpp"
#include "simplnx/Filter/ParameterTraits.hpp"
#include "simplnx/Utilities/DataTypeUtilities.hpp"

namespace nx::core
{
Expand All @@ -14,7 +15,7 @@ class SIMPLNX_EXPORT MultiArraySelectionParameter : public MutableDataParameter
public:
using ValueType = std::vector<DataPath>;
using AllowedTypes = std::set<IArray::ArrayType>;
using AllowedDataTypes = std::set<DataType>;
using AllowedDataTypes = nx::core::DataTypeSetType;
using AllowedComponentShapes = std::vector<IArray::ShapeType>;

MultiArraySelectionParameter() = delete;
Expand Down
20 changes: 20 additions & 0 deletions src/simplnx/Utilities/DataArrayUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "simplnx/Common/Types.hpp"
#include "simplnx/Common/TypesUtility.hpp"
#include "simplnx/Core/Application.hpp"
#include "simplnx/DataStructure/IO/Generic/DataIOCollection.hpp"
#include "simplnx/Utilities/FilterUtilities.hpp"

#include <set>
Expand Down Expand Up @@ -32,6 +34,24 @@ struct InitializeNeighborListFunctor

namespace nx::core
{

std::string GetDataFormatFromPreferences()
{
std::string dataFormat;

auto* preferencesPtr = Application::GetOrCreateInstance()->getPreferences();
if(preferencesPtr->forceOocData())
{
dataFormat = preferencesPtr->largeDataFormat();
}
return dataFormat;
}

std::shared_ptr<DataIOCollection> GetDataCollectionInstance()
{
return Application::GetOrCreateInstance()->getIOCollection();
}

//-----------------------------------------------------------------------------
Result<> CheckValueConverts(const std::string& value, NumericType numericType)
{
Expand Down
26 changes: 17 additions & 9 deletions src/simplnx/Utilities/DataArrayUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "simplnx/Common/Array.hpp"
#include "simplnx/Common/Result.hpp"
#include "simplnx/Core/Application.hpp"
#include "simplnx/DataStructure/AttributeMatrix.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/DataStore.hpp"
Expand All @@ -12,6 +11,7 @@
#include "simplnx/DataStructure/NeighborList.hpp"
#include "simplnx/DataStructure/StringArray.hpp"
#include "simplnx/Filter/Actions/CreateArrayAction.hpp"
#include "simplnx/Filter/IFilter.hpp"
#include "simplnx/Filter/Output.hpp"
#include "simplnx/Parameters/MultiArraySelectionParameter.hpp"
#include "simplnx/Utilities/MemoryUtilities.hpp"
Expand Down Expand Up @@ -345,6 +345,18 @@ uint64 CalculateDataSize(const IDataStore::ShapeType& tupleShape, const IDataSto
return numValues * numComponents * sizeof(T);
}

/**
*
* @return
*/
std::string GetDataFormatFromPreferences();

/**
*
* @return
*/
std::shared_ptr<DataIOCollection> GetDataCollectionInstance();

/**
* @brief Creates a DataStore with the given properties
* @tparam T Primitive Type (int, float, ...)
Expand All @@ -364,13 +376,9 @@ std::shared_ptr<AbstractDataStore<T>> CreateDataStore(const typename IDataStore:
}
case IDataAction::Mode::Execute: {
uint64 dataSize = CalculateDataSize<T>(tupleShape, componentShape);
auto* preferencesPtr = Application::GetOrCreateInstance()->getPreferences();
if(preferencesPtr->forceOocData())
{
dataFormat = preferencesPtr->largeDataFormat();
}
auto ioCollection = Application::GetOrCreateInstance()->getIOCollection();
ioCollection->checkStoreDataFormat(dataSize, dataFormat);
dataFormat = GetDataFormatFromPreferences();
auto ioCollection = GetDataCollectionInstance();
dataFormat = ioCollection->checkStoreDataFormat(dataSize, dataFormat);
return ioCollection->createDataStoreWithType<T>(dataFormat, tupleShape, componentShape);
}
default: {
Expand Down Expand Up @@ -476,7 +484,7 @@ std::shared_ptr<AbstractDataStore<T>> ConvertDataStore(const AbstractDataStore<T
return nullptr;
}

auto ioCollection = Application::GetOrCreateInstance()->getIOCollection();
auto ioCollection = GetDataCollectionInstance();
std::shared_ptr<AbstractDataStore<T>> newStore = ioCollection->createDataStoreWithType<T>(dataFormat, dataStore.getTupleShape(), dataStore.getComponentShape());
if(newStore == nullptr)
{
Expand Down
28 changes: 28 additions & 0 deletions src/simplnx/Utilities/DataTypeUtilities.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

#include "DataTypeUtilities.hpp"

namespace nx::core
{
const std::set<DataType>& GetAllDataTypes()
{
static const DataTypeSetType dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16,
nx::core::DataType::int32, nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64,
nx::core::DataType::float32, nx::core::DataType::float64, nx::core::DataType::boolean};
return dataTypes;
}

const std::set<DataType>& GetAllNumericTypes()
{
static const DataTypeSetType dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16, nx::core::DataType::int32,
nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64, nx::core::DataType::float32, nx::core::DataType::float64};
return dataTypes;
}

const std::set<DataType>& GetIntegerDataTypes()
{
static const DataTypeSetType dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16,
nx::core::DataType::int32, nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64};
return dataTypes;
}

} // namespace nx::core
28 changes: 28 additions & 0 deletions src/simplnx/Utilities/DataTypeUtilities.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "simplnx/Common/Types.hpp"
#include "simplnx/simplnx_export.hpp"

#include <set>

namespace nx::core
{

using DataTypeSetType = std::set<DataType>;

/**
* @brief
*/
SIMPLNX_EXPORT const DataTypeSetType& GetAllDataTypes();

/**
* @brief
*/
SIMPLNX_EXPORT const DataTypeSetType& GetAllNumericTypes();

/**
* @brief
*/
SIMPLNX_EXPORT const DataTypeSetType& GetIntegerDataTypes();

}; // namespace nx::core
Loading
Loading