Alsvinn  0.5.3
The fast FVM simulator with UQ support
Public Types | Public Member Functions | List of all members
alsuq::distribution::DLLDistribution Class Reference

#include <alsuq/distribution/DLLDistribution.hpp>

Inheritance diagram for alsuq::distribution::DLLDistribution:
alsuq::distribution::Distribution

Public Types

typedef void * DLLData
 

Public Member Functions

 DLLDistribution (size_t numberOfSamples, size_t dimension, const Parameters &parameters)
 
virtual ~DLLDistribution ()
 
virtual real generate (generator::Generator &generator, size_t component, size_t sample) override
 Generates the next number from the DLL. More...
 
- Public Member Functions inherited from alsuq::distribution::Distribution
virtual ~Distribution ()
 

Detailed Description

The DLL Distribution loads functions dynamically from a user specified DLL file (shared library) at run time.

This is ideal when you want to use some third party QMC module that you don't want to include into the project

The parameters you can supply are

parameter name description
library

filename of dll

create_function

name of the create function, should have the following signature

void* create_function(int size, int dimension, void* parameters);

use NONE if it is not supplied

delete_function

the function to delete any data created, if create_function is NONE, this is ignored assumes signature

void delete_function(void* data);

generator_function

the name of the genreator function assumes signature

real generator_function(void* data, int size, int dimension, int component, int sample, void* parameters);

make_parameters_function

Name of the function to create the parameter struct assumes the signature

void* make_parameters_function();

delete_parameters_function

name of the function to delete the parameter struct assumes the signature

void delete_parameters_function(void* parameters);

set_parameter_function set the parameter, assumes the signature
void set_parameter_function(void* parameters, const char* key, const char* value);

set_parameter_function will be called for every parameter given to the distribution tag, ie if the xml given was

<distribution>
<type>dll</type>
<library>libfoo.so</library>
...
<optionA>value</optionA>
</distribution>

the following code will essentially be called

parameters = make_parameters_function();
set_parameter_function(parameters, "type", "dll");
set_parameter_function(parameters, "library", "libfoo.so");
// ...
set_parameter_function(parameters, "optionA", "value");
// In addition, we always supply the mpi_node and mpi_size
// (from MPI_Comm_rank and MPI_Comm_size)
set_parameter_function(parameters, "mpi_node", mpi_node_as_string);
set_parameter_function(parameters, "mpi_size", mpi_size_as_string);

To get an idea on how this is called, this is a rough sketch (the code assumes every option is set, there are some if tests to check that the user supplied every function, otherwise they are gracefully skipped):

void init() {
parameters = make_parameters_function();
set_parameter_function(parameters, "type", "dll");
set_parameter_function(parameters, "library", "libfoo.so");
// ...
set_parameter_function(parameters, "optionA", "value");
// In addition, we always supply the mpi_node and mpi_size
// (from MPI_Comm_rank and MPI_Comm_size)
set_parameter_function(parameters, "mpi_node", mpi_node_as_string);
set_parameter_function(parameters, "mpi_size", mpi_size_as_string);
data = create_function(size, dimension, parameters);
// you can assume mpi gets synchronized at this point, that is, we
// will essentially call
MPI_Barrier(MPI_COMM_WORLD);
}
double generate_sample(int component, int sample) {
return generate_function(data, size, dimension, component, sample, parameters);
}
void destruct() {
// first delete the data
delete_function(data);
// then delete the parameters
delete_parameters_function(parameters);
}

Member Typedef Documentation

◆ DLLData

Constructor & Destructor Documentation

◆ DLLDistribution()

alsuq::distribution::DLLDistribution::DLLDistribution ( size_t  numberOfSamples,
size_t  dimension,
const Parameters parameters 
)

◆ ~DLLDistribution()

alsuq::distribution::DLLDistribution::~DLLDistribution ( )
virtual

Member Function Documentation

◆ generate()

real alsuq::distribution::DLLDistribution::generate ( generator::Generator generator,
size_t  component,
size_t  sample 
)
overridevirtual

Generates the next number from the DLL.

Implements alsuq::distribution::Distribution.


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