#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <fiber/field/UniformCartesianArray.hpp>
#include <memcore/MemUsage.hpp>
#undef Verbose
#define Verbose(X) AppVerbose("RUN",X)
static constexpr int
FRAGMENTS_PER_FILE = 6;
static constexpr bool
CREATE_INPUT_FILE = true,
CHECK_FILE_SAVE = false,
CHECK_FILE_COPY_BY_CREATOR_COPY = true,
CHECK_FILE_COPY_BY_DATA_COPY = false;
static constexpr int kB = 1024, MB = kB*kB;
static constexpr memsize_t MEMCORE_CACHESIZE = 8*MB;
void check_file_save()
{
{
BP.load("InputFile.f5");
BP->iterate_timeslices(
true, [&](
double t,
const Slice&S)
{
Verbose(0) << " T=" << t;
{
Verbose(0) <<
" Grid " <<
GId.Name();
{
if (CAB)
{
Verbose(0) << "* File Creator created: *** RAM: "
<< " Cache: "
}
return true;
} );
return true;
} );
return true;
}
);
<< " -- file has been COMPLETELY loaded at this time, thus full available RAM is used here by now -- "
<< " - if file is larger than RAM, then some data have been forgotten again, and will be required to be loaded again when saving the Output file. - "
;
BP->
save(
"SavedInputFile.f5");
}
}
void check_file_copy_by_creator_copy()
{
puts(
"##################### COPY FILE VIA CREATOR COPY ######################");
fflush(
stdout);
{
inBP.load(
"InputFile.f5");
(*outBP).bindToNew("InputFileBoundCopy.f5");
inBP->iterate_timeslices(
true, [&](
double t,
const Slice&S)
{
Verbose(0) << " T=" << t;
{
Verbose(0) <<
" Grid " <<
GId.Name();
{
outBP[t][
"Newly Created Grid"].makeCartesianRepresentation(3);
OutField->setCreatorByName( CAB, FragmentID::Name(
fid ));
Verbose(0) <<
"Field [" <<
theFieldID.Name() <<
"] [" << FragmentID::Name(
fid ) <<
"]"
<< "* File Creator created: *** RAM: "
<< "MB Cache: " << Cache::MemCache()->totalCostMiB() << "MB"
;
return true;
} );
return true;
} );
return true;
}
);
<< "MB Cache: " << Cache::MemCache()->totalCostMiB() << "MB"
<< " -- NO file data have been loaded at this time already, thus NO RAM has been used here by now -- "
;
Assert( Cache::MemCache()->totalCostMiB() == 0.0 );
}
<< "MB Cache: " << Cache::MemCache()->totalCostMiB() << "MB";
Assert( Cache::MemCache()->totalCostMiB() == 0.0 );
}
void check_file_copy_by_data_copy()
{
puts(
"##################### COPY FILE VIA DATA COPY ######################");
fflush(
stdout);
{
inBP.load(
"InputFile.f5");
(*outBP).bindToNew("InputFileViaDataCopy.f5");
inBP->iterate_timeslices(
true, [&](
double t,
const Slice&S)
{
Verbose(0) << " T=" << t;
{
Verbose(0) <<
" Grid " <<
GId.Name();
{
outBP[t][
"Data Copied Grid"].makeCartesianRepresentation(3);
#if 0
OutField->setPersistentDataByName( CAB->create()->copy(), FragmentID::Name(
fid ));
#else
OutField->setPersistentDataByName( CAB->create(), FragmentID::Name(
fid ));
#endif
Verbose(0) <<
"Field [" <<
theFieldID.Name() <<
"] [" << FragmentID::Name(
fid ) <<
"]"
<< " Persistent Creator created: *** RAM: "
<< "MB Cache: " << Cache::MemCache()->totalCostMiB() << "MB"
;
return true;
} );
return true;
} );
return true;
}
);
<< "MB Cache: " << Cache::MemCache()->totalCostMiB() << "MB"
<< " -- file has been PARTIALLY loaded at this time, thus some RAM is used here by now -- "
<< " - if file is larger than RAM, then some data have already been saved to the new file and forgotten by now; they do not need to be loaded again for saving. - "
;
Assert( Cache::MemCache()->totalCostMiB() != 0.0 );
}
<< "MB Cache: " << Cache::MemCache()->totalCostMiB() << "MB";
Assert( Cache::MemCache()->totalCostMiB() == 0.0 );
}
int main()
{
Finit();
if (CREATE_INPUT_FILE)
{
BP->bindToNew("InputFile.f5");
for(int i=0; i<FRAGMENTS_PER_FILE; i++)
{
{
}
{
}
}
}
if (CHECK_FILE_SAVE)
check_file_save();
if (CHECK_FILE_COPY_BY_CREATOR_COPY)
check_file_copy_by_creator_copy();
if (CHECK_FILE_COPY_BY_DATA_COPY)
check_file_copy_by_data_copy();
return 0;
}
Convenience class that implements a pointer to a Bundle object but adds some useful member funtions t...
Definition Bundle.hpp:779
int save(const string &url, const RefPtr< LoaderProgress > &SaveProgress=nullptr, const RefPtrStorageTransformations &ST=nullptr)
Definition Bundle.cpp:1142
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Identifier for Fields within a Grid.
Definition FieldID.hpp:53
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
A grid identifier.
Definition GridID.hpp:29
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
A Skeleton is a set of Representation object, each of them accessed by an Representer object.
Definition Skeleton.hpp:102
Information per time slice, mainly a set of Grid objects that are accessed via GridID objects.
Definition Slice.hpp:36
int iterate_grids(const Functor &F) const
Lambda iterator for bundles, provides Slices: @eode iterate_grids( [](const GridID&GId,...
Definition Slice.hpp:197
MemSizeConfig< sizeof(void *)>::memsize_t memsize_t
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
unsigned long long getMemUsage()
double getRelativeMemUsageMiB()
unsigned long long setInitialMemUsage()
string to_string(const Eagle::FixedArray< ElementType, N > &A, const char *OpenBrace="{", const char *CloseBrace="}", const char *Separator=",")