Skip to content

Commit

Permalink
Remove Antares::Memory::Array (#2187)
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin authored Jun 26, 2024
1 parent 0348175 commit b8f1849
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 320 deletions.
9 changes: 0 additions & 9 deletions src/libs/antares/array/include/antares/array/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,6 @@ class Matrix
template<class U>
void pasteToColumn(uint x, const U* data);

/*!
** \brief Copy values into a given column in the matrix
**
** \param x The column index (zero-based)
** \param data The data to copy
*/
template<class U>
void pasteToColumn(uint x, const Antares::Memory::Array<U>& data);

/*!
** \brief Set a entire column with a given value
**
Expand Down
25 changes: 0 additions & 25 deletions src/libs/antares/array/include/antares/array/matrix.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -488,31 +488,6 @@ void Matrix<T, ReadWriteT>::pasteToColumn(uint x, const U* data)
markAsModified();
}

template<class T, class ReadWriteT>
template<class U>
void Matrix<T, ReadWriteT>::pasteToColumn(uint x, const Antares::Memory::Array<U>& data)
{
assert(x < width and "Invalid column index (bigger than `this->width`)");
ColumnType& column = entry[x];

// if the two types are strictly equal, we can perform some major
// optimisations
if (Yuni::Static::Type::StrictlyEqual<T, U>::Yes)
{
(void)::memcpy(column, data, sizeof(T) * height);
}
else
{
// ...otherwise we have to copy each item by hand in any cases
for (uint y = 0; y != height; ++y)
{
column[y] = (T)data[y];
}
}

markAsModified();
}

template<class T, class ReadWriteT>
void Matrix<T, ReadWriteT>::fillColumn(uint x, const T& value)
{
Expand Down
48 changes: 0 additions & 48 deletions src/libs/antares/memory/include/antares/memory/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,52 +33,6 @@ namespace Antares
class Memory final: public Yuni::Policy::ObjectLevelLockable<Memory>
{
public:
template<class T>
class Array final
{
public:
//! \name Constructors
//@{
/*!
** \brief Default constructor
*/
Array() = default;

/*!
** \brief Constructor from null
*/
explicit Array(const Yuni::NullPtr&);

/*!
** \brief Constructor with an initial allocation size
*/
explicit Array(size_t size);

//! Copy constructor (must be empty)
Array(const Array& copy);

template<class U>
Array(const Array<U>&);

/*!
** \brief Destructor
*/
~Array();
//@}

/*!
** \brief
*/
void allocate(size_t size);

T& operator[](uint i);
const T& operator[](uint i) const;

private:
T* pPointer = nullptr;

}; // class Array

template<class T>
struct Stored final
{
Expand All @@ -101,7 +55,6 @@ class Memory final: public Yuni::Policy::ObjectLevelLockable<Memory>
template<class U>
static void Assign(uint count, U* array, const U& value);

public:
template<class T>
static void Allocate(T*& out, size_t size);

Expand All @@ -117,7 +70,6 @@ class Memory final: public Yuni::Policy::ObjectLevelLockable<Memory>
template<class T>
static void Release(T*& pointer);

public:
//! \name Constructor & Destructor
//@{
/*!
Expand Down
48 changes: 0 additions & 48 deletions src/libs/antares/memory/include/antares/memory/memory.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,6 @@ inline uint64_t Memory::processID() const
return pProcessID;
}

template<class T>
Memory::Array<T>::Array(const Yuni::NullPtr&)
{
}

template<class T>
Memory::Array<T>::Array(const Memory::Array<T>&)
{
}

template<class T>
template<class U>
Memory::Array<T>::Array(const Memory::Array<U>&)
{
}

template<class T>
inline Memory::Array<T>::Array(size_t size)
{
allocate(size);
}

template<class T>
inline Memory::Array<T>::~Array()
{
delete[] pPointer;
pPointer = nullptr;
}

template<class T>
void Memory::Array<T>::allocate(size_t size)
{
delete[] pPointer;
pPointer = new T[size];
}

template<class T>
T& Memory::Array<T>::operator[](uint i)
{
return (T&)pPointer[i];
}

template<class T>
const T& Memory::Array<T>::operator[](uint i) const
{
return (const T&)pPointer[i];
}

template<class T>
inline void Memory::Release(T*& pointer)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,11 @@
#ifndef __SOLVER_VARIABLE_STORAGE_MINMAX_DATA_H__
#define __SOLVER_VARIABLE_STORAGE_MINMAX_DATA_H__

#include <antares/memory/memory.h>
#include <antares/study/study.h>
#include <vector>

#include "antares/solver/variable/storage/intermediate.h"

namespace Antares
{
namespace Solver
{
namespace Variable
{
namespace R
{
namespace AllYears
namespace Antares::Solver::Variable::R::AllYears
{
class MinMaxData
{
Expand All @@ -44,37 +36,23 @@ class MinMaxData
uint32_t indice;
};

public:
//! \name Constructor & Destructor
//@{
/*!
** \brief Default constructor
*/
MinMaxData();
//! Destructor
~MinMaxData();

void initialize();
MinMaxData() = default;
~MinMaxData() = default;

void resetInf();
void resetSup();

void mergeInf(uint year, const IntermediateValues& rhs);
void mergeSup(uint year, const IntermediateValues& rhs);

public:
Data annual;
Data monthly[maxMonths];
Data weekly[maxWeeksInAYear];
Data daily[maxDaysInAYear];
Antares::Memory::Stored<Data>::Type hourly;
std::vector<Data> annual{1};
std::vector<Data> monthly{maxMonths};
std::vector<Data> weekly{maxWeeksInAYear};
std::vector<Data> daily{maxDaysInAYear};
std::vector<Data> hourly{maxHoursInAYear};

}; // class MinMaxData

} // namespace AllYears
} // namespace R
} // namespace Variable
} // namespace Solver
} // namespace Antares
} // namespace Antares::Solver::Variable::R::AllYears

#endif // __SOLVER_VARIABLE_STORAGE_MINMAX_DATA_H__
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ struct MinMaxBase: public NextT
{
case Category::hourly:
InternalExportIndices<maxHoursInAYear, VCardT>(report,
Memory::RawPointer(minmax.hourly),
Memory::RawPointer(minmax.hourly.data()),
fileLevel);
break;
case Category::daily:
InternalExportIndices<maxDaysInAYear, VCardT>(report, minmax.daily, fileLevel);
InternalExportIndices<maxDaysInAYear, VCardT>(report, minmax.daily.data(), fileLevel);
break;
case Category::weekly:
InternalExportIndices<maxWeeksInAYear, VCardT>(report, minmax.weekly, fileLevel);
InternalExportIndices<maxWeeksInAYear, VCardT>(report, minmax.weekly.data(), fileLevel);
break;
case Category::monthly:
InternalExportIndices<maxMonths, VCardT>(report, minmax.monthly, fileLevel);
InternalExportIndices<maxMonths, VCardT>(report, minmax.monthly.data(), fileLevel);
break;
case Category::annual:
InternalExportIndices<1, VCardT>(report, &minmax.annual, fileLevel);
InternalExportIndices<1, VCardT>(report, minmax.annual.data(), fileLevel);
break;
}
}
Expand All @@ -107,19 +107,19 @@ struct MinMaxBase: public NextT
{
case Category::hourly:
InternalExportValues<maxHoursInAYear, VCardT>(report,
Memory::RawPointer(minmax.hourly));
Memory::RawPointer(minmax.hourly.data()));
break;
case Category::daily:
InternalExportValues<maxDaysInAYear, VCardT>(report, minmax.daily);
InternalExportValues<maxDaysInAYear, VCardT>(report, minmax.daily.data());
break;
case Category::weekly:
InternalExportValues<maxWeeksInAYear, VCardT>(report, minmax.weekly);
InternalExportValues<maxWeeksInAYear, VCardT>(report, minmax.weekly.data());
break;
case Category::monthly:
InternalExportValues<maxMonths, VCardT>(report, minmax.monthly);
InternalExportValues<maxMonths, VCardT>(report, minmax.monthly.data());
break;
case Category::annual:
InternalExportValues<1, VCardT>(report, &minmax.annual);
InternalExportValues<1, VCardT>(report, minmax.annual.data());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace AllYears
template<bool OpInferior, class NextT>
inline void MinMaxBase<OpInferior, NextT>::initializeFromStudy(Data::Study& study)
{
minmax.initialize();
// Next
NextType::initializeFromStudy(study);
}
Expand Down
Loading

0 comments on commit b8f1849

Please sign in to comment.