31 #include <boost/shared_ptr.hpp>
32 #include <boost/thread.hpp>
33 #include <boost/filesystem.hpp>
52 template<
class Matrix,
class SymmGroup>
class Boundary;
53 template<
class Matrix,
class SymmGroup>
class MPSTensor;
54 template<
class Matrix,
class SymmGroup>
class block_matrix;
56 namespace alps {
namespace numeric {
57 template <
typename T,
typename MemoryBlock>
class matrix;
75 template<
class T>
static void fetch(T& o){}
76 template<
class T>
static void evict(T& o){}
77 template<
class T>
static void drop(T& o){}
85 template<
class Matrix,
class SymmGroup>
90 std::ofstream ofs(fp.c_str(), std::ofstream::binary);
93 for(
size_t b = 0; b < loop_max; ++b){
94 for (std::size_t k = 0; k < o[b].n_blocks(); ++k){
96 for (std::size_t c = 0; c <
num_cols(m); ++c)
97 ofs.write((
char*)(&m(0, c)),
num_rows(m)*
98 sizeof(
typename Matrix::value_type)/
sizeof(
char));
109 template<
class Matrix,
class SymmGroup>
114 std::ifstream ifs(fp.c_str(), std::ifstream::binary);
117 for(
size_t b = 0; b < loop_max; ++b){
118 for (std::size_t k = 0; k < o[b].n_blocks(); ++k){
119 o[b][k] = Matrix(o[b].left_basis()[k].second,
120 o[b].right_basis()[k].second);
123 sizeof(
typename Matrix::value_type)/
sizeof(
char));
133 template<
class Matrix,
class SymmGroup>
139 for (std::size_t b = 0; b < o.
aux_dim(); ++b)
140 for (std::size_t k = 0; k < o[b].n_blocks(); ++k){
180 descriptor::operator=(rhs);
221 static disk singleton;
225 maquis::cout <<
"Temporary storage enabled in " << path <<
"\n";
233 return (
instance().
path + boost::lexical_cast<std::string>(sid));
256 template<
class Matrix,
class SymmGroup>
267 if(!parms[
"storagedir"].empty()){
268 boost::filesystem::path dp = boost::filesystem::unique_path(parms[
"storagedir"].as<std::string>() + std::string(
"/storage_temp_%%%%%%%%%%%%/"));
270 boost::filesystem::create_directories(dp);
272 maquis::cerr <<
"Error creating dir/file at " << dp <<
". Try different 'storagedir'.\n";
277 maquis::cout <<
"Temporary storage is disabled\n";
static void evict(serializable< T > &t)
static void pin(serializable< T > &t)
static std::string fp(size_t sid)
static void drop(serializable< T > &t)
static void fetch(serializable< T > &t)
static void prefetch(T &o)
static void evict(MPSTensor< Matrix, SymmGroup > &t)
static void track(descriptor *d)
alps::numeric::matrix< T, std::vector< T > > type
alps::numeric::matrix< double > matrix
std::size_t num_rows(maquis::dmrg::one_matrix< T > const &m)
evict_request(std::string fp, Boundary< Matrix, SymmGroup > *ptr)
static void prefetch(serializable< T > &t)
static void untrack(descriptor *d)
std::size_t num_cols(maquis::dmrg::one_matrix< T > const &m)
drop_request(std::string fp, Boundary< Matrix, SymmGroup > *ptr)
Logger< storage::archive > log
std::size_t aux_dim() const
fetch_request(std::string fp, Boundary< Matrix, SymmGroup > *ptr)
static void init(const std::string &path)
enum storage::disk::descriptor::@0 state
void thread(boost::thread *t)
serializable & operator=(const serializable &rhs)
std::vector< descriptor * > queue