ControlEnv

From Daxtoolkit
Jump to: navigation, search

Discussion of how we convert a collection of worklets to filters.


ControlEnvDaigram.png

Source

This separates the dataset objects ( ImageData, UnstructuredData, etc ) from the control environment. Given a dataset it generates port objects needed to connect the dataset to filters. This is equivalent to the trivial producer in VTK.

void ChangeGridPipeline()
{
  dax::cont::StructuredGrid grid = CreateInputStructure(32);
  Source<dax::cont::StructuredGrid> source(grid);
}

Filter

The filter is the pipeline representation of the worklet. Its only job is to make sure filters and sources upstream of it are executed before it is. The filter passes all the execution of the worklet down to the module class.

void ChangeGridPipeline()
{
  dax::cont::StructuredGrid grid = CreateInputStructure(32);
  Source<dax::cont::StructuredGrid> source(grid);

  Filter< Square > Filter1( source.pointField("pointArray") );
  Filter< NewGridOutput > Filter2( Filter1.topology() );
  Filter< Sine > Filter3( Filter2.pointField("pointArray") );
  
  Filter3.execute();  
}

Port

Connects Filters and Sources together. It contains all the information needed to connect filters together including:

  • What generated the Port
  • What dataset to work on
  • What Array from the dataset you should use
  • What type of array it is ( point field, cell field, point coordinates, topology ).

Module

The module has two jobs. The first is that it validates the pipeline connection by making sure the correct number of ports have been passed in and it validates that the ports are of the correct type that are coming in.

The second job that the module has is too execute the workletProxy on the correct device ( CUDA / OpenMP ). Currently it can handle only a single device but that can be expanded in the future.

template < typename Worklet>
class PointToCellModule : public Module //takes a point property and converts to a cell property
{
public:
  //copy inputs data, and set field to cell
  PointToCellModule(const Port& input):
    Module(Worklet::NumInputs,Worklet::NumOutputs,field_cells(),input)
  {    
    STATIC_ASSERT(Worklet::NumInputs==1,Incorrect_Number_Of_Parameters);
  }

  void run()
  {
    Worklet()(this->InputPorts,this->OutputPorts);
  }
};

WorkletProxy

Is a auto generated class that the module calls to execute the worklet. It takes all the Modules inputs and properly passes them to the worklet and than fills the outputs of the Module with the correct values.

It properly handles all the necessary code to move the data from the host to the device.

struct SineWorkletProxy
{
  enum {NumInputs = 1,
        NumOutputs = 1};

  template<typename T, typename U>
  DAX_EXEC_CONT_EXPORT void operator()(const T& in, U& out)
  {

  dax::cont::HostArray<dax::Scalar> *input;
  ConvertType(in[0].property(),input);

  dax::cont::HostArray<dax::Scalar> *output;
  ConvertType(out[0].property(),output);

  dax::cont::HostArray<dax::Scalar>::iterator inIt;
  dax::cont::HostArray<dax::Scalar>::iterator outIt;

  for(inIt=input->begin(), outIt=output->begin();
      inIt!=input->end();
      ++inIt, ++outIt)
    {
    worklets::Sine(*inIt,*outIt);
    }
  }
};


Questions

  • Better name for Port
  • Should we use functions rather than methods for filter connections:
void ChangeGridPipeline()
{
  dax::cont::StructuredGrid grid = CreateInputStructure(32);
  Source<dax::cont::StructuredGrid> source(grid);

  Filter< Square > Filter1( pointField(source,"pointArray") );
  Filter< NewGridOutput > Filter2( topology(Filter1) );
  Filter< Sine > Filter3( pointField(Filter2, "pointArray") );

  execute(Filter3);
}