Class AMSWorkflow

Class Documentation

class AMSWorkflow

Public Functions

inline AMSWorkflow(std::string &surrogate_path, std::string &domain_name, float threshold, int _pId = 0, int _wSize = 1, bool store_data = true)
inline std::string getDBFilename() const
inline void set_exec_policy(AMSExecPolicy policy)
inline bool should_load_balance() const
inline ~AMSWorkflow()
inline void evaluate(DomainLambda CallBack, ams::MutableArrayRef<torch::Tensor> Ins, ams::MutableArrayRef<torch::Tensor> InOuts, ams::MutableArrayRef<torch::Tensor> Outs)

This is the main entry point of AMSLib and replaces the original execution path of the application.

The function corresponds to the main driver of the AMSLib. Assuming an original ‘foo’ function void foo ( void *cls, int numElements, void **inputs, void **outputs){ parallel_for(I : numElements){ cls->physics(inputs[0][I], outputs[0][I]); } }

The AMS transformation would functionaly look like this: void AMSfoo ( void *cls, int numElements, void **inputs, void **outputs){ parallel_for(I : numElements){ if ( UQ (I) ){ Surrogate(inputs[0][I], outputs[0][I]) } else{ cls->physics(inputs[0][I], outputs[0][I]); DB->Store(inputs[0][I], outputs[0][I]); } } }

Yet, AMS assumes a SPMD physics function (in the example cls->physics). Therefore, the AMS transformation is taking place at the level of the SPMD execution. The following transformation is equivalent void AMSfoo( void*cls, int numElements, void **inputs, void **outputs){ predicates = UQ(inputs, numElements); modelInputs, physicsInputs = partition(predicates,inputs); modelOuputs, physicsOutputs = partition(predicates, output); foo(cls, physicsInputs.size(), physicsInputs, physicsOutputs); surrogate(modelInputs, modelOuputs, modelOuputs.size()); DB->Store(physicsInputs, physicsOutputs); concatenate(outptuts, modelOuputs, predicate); }

This transformation can exploit the parallel nature of all the required steps.

Parameters:
  • probDescr[in] an opaque type that will be forwarded to the application upcall

  • totalElements[in] the total number of elements to apply the SPMD function on

  • inputs[in] the inputs of the computation.

  • outputs[out] the computed outputs.

  • Comm[in] The MPI Communicatotor for all ranks participating in the SPMD execution.

inline std::string getDBName()

Public Static Functions

static inline SmallVector<torch::Tensor> subSelectTensors(ArrayRef<torch::Tensor> Tensors, torch::Tensor &Mask)
static inline void ScatterPhysicOutputsToOrigDomain(ArrayRef<torch::Tensor> computedDomain, torch::Tensor &Predicate, MutableArrayRef<torch::Tensor> entireDomain)
static inline int MLDomainToApplication(torch::Tensor Src, MutableArrayRef<torch::Tensor> Dest, torch::Tensor Predicate, int offset)