42 #ifndef TEUCHOS_WORKSPACE_HPP
43 #define TEUCHOS_WORKSPACE_HPP
133 size_t num_bytes()
const;
135 char* workspace_ptr();
137 const char* workspace_ptr()
const;
148 static void*
operator new(size_t);
149 static void operator delete(
void*);
252 static void*
operator new(size_t);
253 static void operator delete(
void*);
275 size_t num_bytes_total()
const;
278 size_t num_bytes_remaining()
const;
284 int num_static_allocations()
const;
290 int num_dyn_allocations()
const;
294 size_t num_current_bytes_total();
298 size_t num_max_bytes_needed()
const;
303 void protected_initialize(
size_t num_bytes);
355 : raw_workspace_(workspace_store,sizeof(T)*num_elements), call_constructors_(call_constructors)
359 for(
size_t k = 0; k < num_elements; ++k, raw_ptr +=
sizeof(T) )
368 if(call_constructors_) {
369 const size_t num_elements = this->size();
370 char* raw_ptr = raw_workspace_.workspace_ptr();
371 for(
size_t k = 0; k < num_elements; ++k, raw_ptr +=
sizeof(T) )
372 reinterpret_cast<T*
>(raw_ptr)->~T();
380 return raw_workspace_.num_bytes() /
sizeof(T);
387 return ( size() ? &(*
this)[0] : 0 );
394 return ( size() ? &(*
this)[0] : 0 );
404 return reinterpret_cast<T*
>(raw_workspace_.workspace_ptr())[i];
420 return arrayView<T>( &(*this)[0], size() );
430 return arrayView<const T>( &(*this)[0], size() );
447 #ifdef __PGI // Should not have to define this but pgCC is complaining!
541 void RawWorkspace::operator
delete(
void*)
548 #endif // TEUCHOS_WORKSPACE_HPP
WorkspaceStore * workspace_store_
size_t num_current_bytes_total_
WorkspaceStoreInitializeable(size_t num_bytes=0)
Default constructs to no memory set and will dynamically allocate all memory requested.
size_t size() const
Return the number of elements in the array.
Encapulsation object for raw temporary workspace that has been allocated. These objects can only be c...
Templated class for workspace creation.
ArrayView< T > operator()()
Return a non-const array view.
~Workspace()
The destructor on the elements will only be called if call_constructors == true was passed to the con...
TEUCHOSCORE_LIB_DLL_EXPORT void set_default_workspace_store(const Teuchos::RCP< WorkspaceStore > &default_workspace_store)
Set pointer to global workspace object.
WorkspaceStore class that can be used to actually reinitialize memory.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
size_t num_bytes() const
Return the number of bytes of raw workspace.
size_t num_current_bytes_total()
Return the total number of bytes currently allocated.. This is the total number of bytes currently be...
T & operator[](size_t i)
Non-const zero based element access.
int num_static_allocations_
#define TEUCHOSCORE_LIB_DLL_EXPORT
T * getRawPtr()
Return a raw pointer to the beginning of the array or null if unsized.
size_t num_max_bytes_needed_
RawWorkspace raw_workspace_
Workspace & operator=(const RawWorkspace &)
Workspace encapsulation class.
size_t num_max_bytes_needed() const
Return the maximum storage in bytes needed. This is the maximum total amount of * storage that was ne...
int num_dyn_allocations() const
Return the number of dynamic memory allocations granted thus far. This is the number of memory alloca...
int num_static_allocations() const
Return the number of static memory allocations granted thus far. This is the number of memory allocat...
Smart reference counting pointer class for automatic garbage collection.
void initialize(size_t num_bytes)
Set the size block of memory to be given as workspace.
void protected_initialize(size_t num_bytes)
Partial specialization of ArrayView for const T.
char * workspace_ptr()
Give a raw pointer to the beginning of the workspace.
size_t num_bytes_remaining() const
Return the number of bytes remaining currently.
size_t num_bytes_total() const
Return the total number of bytes that where initially allocated.
TEUCHOSCORE_LIB_DLL_EXPORT void print_memory_usage_stats(const WorkspaceStore *workspace_store, std::ostream &out)
Print statistics on memory usage.
Reference-counted pointer class and non-member templated function implementations.
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()
Get the global workspace object set by set_default_workspace_store().