Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80760714
fft_plan_manager.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Sep 2, 11:25
Size
3 KB
Mime Type
text/x-c++
Expires
Wed, Sep 4, 11:25 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20437707
Attached To
rTAMAAS tamaas
fft_plan_manager.cpp
View Options
/**
* @file
* @section LICENSE
*
* Copyright (©) 2016-19 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fft_plan_manager.hh"
#include "fftransform_fftw.hh"
#if defined(USE_CUFFT)
#include "fftransform_cufft.hh"
#endif
#include <list>
/* -------------------------------------------------------------------------- */
namespace tamaas {
/* -------------------------------------------------------------------------- */
FFTPlanManager::~FFTPlanManager() { clean(); }
/* -------------------------------------------------------------------------- */
namespace detail {
/// class purely for singleton instanciation
struct PublicFFTPlanManager : public FFTPlanManager {};
} // namespace detail
FFTPlanManager& FFTPlanManager::get() {
if (FFTPlanManager::singleton == nullptr)
FFTPlanManager::singleton =
std::make_unique<detail::PublicFFTPlanManager>();
return *FFTPlanManager::singleton;
}
/* -------------------------------------------------------------------------- */
void FFTPlanManager::clean() {
for (auto pair : plans) {
delete std::get<0>(pair.second);
delete std::get<1>(pair.second);
}
plans.clear();
}
/* -------------------------------------------------------------------------- */
template <>
void FFTPlanManager::destroyPlan<Real>(const Real* some) {
std::list<FFTMap::key_type> pairs;
for (auto & pair : plans) {
if (pair.first.first == some) { // C++14 use get<T>(pair.first)
delete std::get<0>(pair.second);
delete std::get<1>(pair.second);
pairs.push_back(pair.first);
}
}
for (auto & pair : pairs)
plans.erase(pair);
}
/* -------------------------------------------------------------------------- */
template <>
void FFTPlanManager::destroyPlan<Complex>(const Complex* some) {
std::list<FFTMap::key_type> pairs;
for (auto & pair : plans) {
if (pair.first.second == some) {
delete std::get<0>(pair.second);
delete std::get<1>(pair.second);
pairs.push_back(pair.first);
}
}
for (auto & pair : pairs)
plans.erase(pair);
}
/* -------------------------------------------------------------------------- */
std::unique_ptr<FFTPlanManager> FFTPlanManager::singleton = nullptr;
/* -------------------------------------------------------------------------- */
} // namespace tamaas
Event Timeline
Log In to Comment