MADNESS  0.10.1
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
madness::profiling::TaskProfiler Class Reference

This class collects and prints task profiling data. More...

#include <thread.h>

Collaboration diagram for madness::profiling::TaskProfiler:
Collaboration graph
[legend]

Public Member Functions

 TaskProfiler ()
 Default constructor. More...
 
 ~TaskProfiler ()
 Destructor. More...
 
TaskEventListnew_list (const std::size_t nmax)
 Create a new task event list. More...
 
void write_to_file ()
 Write the profile data to file. More...
 

Static Public Attributes

static const char * output_file_name_
 The output file name. More...
 

Private Member Functions

 TaskProfiler (const TaskProfiler &)=delete
 
TaskProfileroperator= (const TaskProfiler &)=delete
 

Private Attributes

TaskEventListBasehead_
 The head of the linked list of data. More...
 
TaskEventListBasetail_
 The tail of the linked list of data. More...
 

Static Private Attributes

static Mutex output_mutex_
 Mutex used to lock the output file. More...
 

Detailed Description

This class collects and prints task profiling data.

Note
Each thread has its own TaskProfiler object, so only one thread will ever operate on this object at a time and all operations are inheirently thread safe.

Constructor & Destructor Documentation

◆ TaskProfiler() [1/2]

madness::profiling::TaskProfiler::TaskProfiler ( const TaskProfiler )
privatedelete

◆ TaskProfiler() [2/2]

madness::profiling::TaskProfiler::TaskProfiler ( )
inline

Default constructor.

◆ ~TaskProfiler()

madness::profiling::TaskProfiler::~TaskProfiler ( )
inline

Member Function Documentation

◆ new_list()

TaskEventList* madness::profiling::TaskProfiler::new_list ( const std::size_t  nmax)
inline

Create a new task event list.

Parameters
[in]nmaxThe maximum number of elements that the list can contain.
Returns
A new task event list.

References head_, madness::profiling::TaskEventListBase::insert(), and tail_.

Referenced by madness::ThreadPool::run_task(), and madness::ThreadPool::run_tasks().

◆ operator=()

TaskProfiler& madness::profiling::TaskProfiler::operator= ( const TaskProfiler )
privatedelete

◆ write_to_file()

void madness::profiling::TaskProfiler::write_to_file ( )

Write the profile data to file.

The data is cleared after it is written to the file, so this function may be called more than once.

Warning
This function should only be called from the thread that owns it, otherwise data will likely be corrupted.
Note
This function is thread safe, in that it may be called by different objects in different threads simultaneously.

References SafeMPI::COMM_WORLD, SafeMPI::Intracomm::Get_rank(), head_, madness::profiling::TaskEventListBase::next(), output_file_name_, output_mutex_, madness::ThreadPool::size(), and tail_.

Referenced by madness::ThreadPool::end(), and madness::ThreadPool::thread_main().

Member Data Documentation

◆ head_

TaskEventListBase* madness::profiling::TaskProfiler::head_
private

The head of the linked list of data.

Referenced by ~TaskProfiler(), new_list(), and write_to_file().

◆ output_file_name_

const char * madness::profiling::TaskProfiler::output_file_name_
static

The output file name.

This variable is initialized by ThreadPool::begin and is assigned the value given by the environment variable MAD_TASKPROFILER_NAME.

Referenced by madness::ThreadPool::begin(), and write_to_file().

◆ output_mutex_

Mutex madness::profiling::TaskProfiler::output_mutex_
staticprivate

Mutex used to lock the output file.

Referenced by write_to_file().

◆ tail_

TaskEventListBase* madness::profiling::TaskProfiler::tail_
private

The tail of the linked list of data.

Referenced by new_list(), and write_to_file().


The documentation for this class was generated from the following files: