AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions
Aqua::CalcServer::Python Class Reference

Execute a Python script. More...

#include <CalcServer/Python.h>

Inheritance diagram for Aqua::CalcServer::Python:
Inheritance graph
[legend]
Collaboration diagram for Aqua::CalcServer::Python:
Collaboration graph
[legend]

Public Member Functions

 Python (const std::string tool_name, const std::string script, bool once=false)
 Constructor.
 
 ~Python ()
 Destructor.
 
void setup ()
 Initialize the tool.
 
- Public Member Functions inherited from Aqua::CalcServer::Tool
 Tool (const std::string tool_name, bool once=false)
 
virtual ~Tool ()
 
void name (const std::string tool_name)
 
const std::string name ()
 
virtual void setup ()
 
virtual void execute ()
 Execute the tool measuring the elapsed time.
 
virtual Toolnext_tool ()
 
size_t allocatedMemory () const
 
unsigned int used_times () const
 
float elapsedTime (bool averaged=true) const
 
float elapsedTimeVariance () const
 
float elapsedTimeDeviation () const
 
virtual const int scope_modifier ()
 

Protected Member Functions

cl_event _execute (const std::vector< cl_event > events)
 
void initPython ()
 Initialize the Python interpreter.
 
void load ()
 Load the script and extract the callable function.
 
- Protected Member Functions inherited from Aqua::CalcServer::Tool
int id_in_pipeline ()
 
void next_tool (Tool *tool)
 
void allocatedMemory (size_t mem_size)
 
virtual cl_event _execute (const std::vector< cl_event > events)
 
void addElapsedTime (float elapsed_time)
 Add new data to the average and squared elapsed times.
 
void setDependencies (std::vector< std::string > var_names)
 Set the depedencies of the tool.
 
void setDependencies (std::vector< InputOutput::Variable * > vars)
 Set the depedencies of the tool.
 
const std::vector< InputOutput::Variable * > getDependencies ()
 Get the depedencies of the tool.
 

Additional Inherited Members

- Static Protected Member Functions inherited from Aqua::CalcServer::Tool
static std::vector< cl_kernel > compile (const std::string source, const std::vector< std::string > names, const std::string flags="")
 Compile an OpenCL source code and generate the corresponding kernel.
 
static cl_kernel compile_kernel (const std::string source, const std::string kernel_name, const std::string flags="")
 Compile an OpenCL source code and generate the corresponding kernel.
 

Detailed Description

Execute a Python script.

The Python script should has a function main which will be called each time step, when execute is called.

AQUAgpusph is providing a module called aquagpusph which allows the Python script to get and set variable values.

Constructor & Destructor Documentation

◆ Python()

Aqua::CalcServer::Python::Python ( const std::string  tool_name,
const std::string  script,
bool  once = false 
)

Constructor.

Parameters
tool_nameTool name.
scriptPython script path.
onceRun this tool just once. Useful to make initializations.

◆ ~Python()

Aqua::CalcServer::Python::~Python ( )

Destructor.

Member Function Documentation

◆ _execute()

cl_event Aqua::CalcServer::Python::_execute ( const std::vector< cl_event >  events)
protectedvirtual

Execute the tool

Parameters
eventsList of events that shall be waited before safe execution
Returns
OpenCL event to be waited before accesing the dependencies

Reimplemented from Aqua::CalcServer::Tool.

◆ initPython()

void Aqua::CalcServer::Python::initPython ( )
protected

Initialize the Python interpreter.

This method is safely creating the Python environment just one time, adding the execution folder to the system path (in order to import modules).

Here is the call graph for this function:

◆ load()

void Aqua::CalcServer::Python::load ( )
protected

Load the script and extract the callable function.

Here is the call graph for this function:

◆ setup()

void Aqua::CalcServer::Python::setup ( )
virtual

Initialize the tool.

Reimplemented from Aqua::CalcServer::Tool.

Here is the call graph for this function:

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