/usr/include/TiledArray/madness.h is in libtiledarray-dev 0.6.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /*
* This file is a part of TiledArray.
* Copyright (C) 2013 Virginia Tech
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef TILEDARRAY_MADNESS_H__INCLUDED
#define TILEDARRAY_MADNESS_H__INCLUDED
// This needs to be defined before world/worldreduce.h and world/worlddc.h
#ifndef WORLD_INSTANTIATE_STATIC_TEMPLATES
#define WORLD_INSTANTIATE_STATIC_TEMPLATES
#endif // WORLD_INSTANTIATE_STATIC_TEMPLATES
#include <memory>
#pragma GCC diagnostic push
#pragma GCC system_header
#include <madness/world/MADworld.h>
#include <madness/tensor/cblas.h>
#pragma GCC diagnostic pop
#include <TiledArray/error.h>
namespace TiledArray {
// Import some MADNESS classes into TiledArray for convenience.
using madness::World;
using madness::Future;
using madness::initialize;
using madness::finalize;
// it is useful to specify the implicit execution context for the TiledArray
// DSL on a per-scope basis ... this assumes that only 1 thread (usually, main)
// parses TiledArray DSL
namespace detail {
struct default_world {
static World& get() {
if (!world()) {
TA_USER_ASSERT(madness::initialized(),
"TiledArray::detail::default_world::get() called "
"before madness::initialize()");
world() = &madness::World::get_default();
}
return *world();
}
static void set(World* w) {
world() = w;
}
private:
static World*& world() {
static World* world_ = nullptr;
return world_;
}
};
} // namespace detail
/// \brief Sets the default World to \c world .
/// Expressions that follow this call will use
/// \c world as the default execution context (the use of default World can be
/// overridden by explicit mechanisms for specifying the execution context,
/// like Expr::set_world() or assigning an expression to a DistArray that has
/// already been initialized with a World).
///
/// \note set_default_world() and get_default_world() are only useful if 1
/// thread (usually, the main thread ) creates TiledArray expressions.
///
/// \param world a World object which will become the new default
static void set_default_world(World& world) {
return detail::default_world::set(&world);
}
/// Accesses the default World.
/// \return the current default World
static World& get_default_world() {
return detail::default_world::get();
}
/// Resets the default World to the world returned by
/// madness::World::get_default(), i.e. the World that spans all processes
static void reset_default_world() {
return detail::default_world::set(nullptr);
}
namespace {
auto world_resetter = [](World* w) { set_default_world(*w); };
} // namespace detail
/// Sets the default World to \c world and returns a smart pointer to
/// the current default World. Releasing this pointer
/// will automatically set the default World to the World that it points.
/// Thus use this as follows:
/// \code
/// {
/// auto popper = push_default_world(new_world);
/// assert(&new_world == &get_default_world()); // new_world is now default
/// ... // TiledArray expressions will use new_world now
/// } // popper destructor resets the default World back to the old value
/// \endcode
///
/// \param world a World object which will become the new default
/// \return a smart pointer to the current default World (i.e. not \c world)
/// whose deleter will reset the default World back to the stored
/// value
static std::unique_ptr<World, decltype(world_resetter)>
push_default_world(World& world) {
World* current_world = &get_default_world();
set_default_world(world);
return std::unique_ptr<World, decltype(world_resetter)>(
current_world, world_resetter);
}
} // namespace TiledArray
#endif // TILEDARRAY_MADNESS_H__INCLUDED
|