API

The Hybrid Task Graph Scheduler API
aids developers in representing algorithms as hybrid pipeline workflows using hybrid task graphs



What is HTGS?

HTGS is the Hybrid Task Graph Scheduler API that is designed to aid in creating task graphs for algorithms to obtain performance across CPUs and multiple-co-processors.

Ease of use

C++ Object-oriented design to quickly port existing computational functions into tasks to build complex task graphs.

Memory Management

Connect any task to memory(CPU or GPU) to keep your algorithms running within memory limits.

Extreme Pipelining

Every task is bound to one or more threads, such that each task will compute asynchronously with all other tasks in the graph.

Execution across ALL CPUs and GPUs

Decompose your problem domain and distribute data to execution pipelines, where each pipeline runs on a separate GPU taking advantage of distributed multi-GPU computation.

Customize

The API is templatized as easy-to-use interfaces to quickly create new tasks that can be shared and used for a wide variety of algorithms.

Lightweight and easy to Install

The entire API is a series of header files. Just include the header files in your project and begin creating task graphs. Includes CMake configuration to generate documentation and run unit tests.

Features

Get Started

Installation

  • Dependencies:
  • cmake v2.7+
  • g++/gcc v4.8.4+ (C++11)
  • pthreads
  • (Optional) doxygen
  • CMake Options:
  • CMAKE_INSTALL_PREFIX - Where to install HTGS (and documentation)
  • BUILD_DOXYGEN - Creates doxygen documentation (view online at: Documentation)
  • RUN_GTEST - Compiles and runs google unit tests for HTGS ('make run-test' to re-run)

 :$ git clone https://github.com/usnistgov/HTGS.git
 :$ cd <HTGS_Directory>
 :<HTGS_Directory>$ mkdir build && cd build
 :<HTGS_Directory>/build$ ccmake ../         (or cmake-gui)

 'Configure' and setup cmake parameters
 'Configure' and 'Build'

 :<HTGS_Directory>/build$ make
 :<HTGS_Directory>/build$ make install
                     

Using HTGS

  • HTGS API:
  • htgs::IData
  • htgs::ITask
  • htgs::TaskGraph
  • htgs::Runtime

Brief example of adding two numbers using HTGS; filename: "main.cpp". (As seen in Tutorial 1):


  #include <htgs/api/IData.hpp>
  #include <htgs/api/ITask.hpp>
  #include <htgs/api/TaskGraphConf.hpp>
  #include <htgs/api/TaskGraphRuntime.hpp>

  class InputData : public htgs::IData
  {
    public:
      InputData(int x, int y) : x(x), y(y) {}
      int getX() const { return x; }
      int getY() const { return y; }
    private:
      int x, y;
  };

  class OutputData : public htgs::IData
  {
    public:
      OutputData(int result) : result(result) {}
      int getResult() const { return result; }
    private:
      int result;
  };

  class AddTask : public htgs::ITask<InputData, OutputData>
  {
    public:
      virtual AddTask *copy() { return new AddTask(); }
      virtual void executeTask(std::shared_ptr<InputData> data) {
        int sum = data->getX() + data->getY();
        this->addResult(new OutputData(sum));
      }
  };

  int main() {
    AddTask *addTask = new AddTask();
    auto taskGraph = new htgs::TaskGraphConf<InputData, OutputData>();
    taskGraph->setGraphConsumerTask(addTask);
    taskGraph->addGraphProducerTask(addTask);

    auto runtime = new htgs::TaskGraphRuntime(taskGraph);
    runtime->executeRuntime();

    int numData = 10;
    for (int i = 0; i < numData; i++) {
      auto inputData = new InputData(i, i);
      taskGraph->produceData(inputData);
    }

    taskGraph->finishedProducingData();

    runtime->waitForRuntime();

    while(!taskGraph->isOutputTerminated()) {
      auto data = taskGraph->consumeData();
      std::cout << "Result: " << data->getResult() << std::endl;
    }

    delete runtime;
  }
                     
  • Compile:
  • g++ -I <HTGS_INSTALL_DIR>/include main.cpp -std=c++11 -pthread

  • Sample Output:
  • :$./a.out
  • Result: 0
  • Result: 2
  • Result: 4
  • Result: 6
  • Result: 8
  • Result: 10
  • Result: 12
  • Result: 14
  • Result: 16
  • Result: 18

Full Documentation

For full explanation of Tutorial 1 and other tutorials showing how to use all of the components, please visit the doxygen documentation below.

More on Doxygen

Cite Us In Your Research

If you are using the HTGS API in your research please use the following references to cite us.


Blattner T., Keyrouz W., The Hybrid Task Graph Scheduler API, (2017), GitHub repository, https:// github.com/usnistgov/HTGS


Blattner, T., Keyrouz, W., Bhattacharyya, S.S. et al. J Sign Process Syst (2017) 89: 457. https://doi.org/10.1007/s11265-017-1262-6
download pdf, view article

Disclaimer

NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.

NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.

You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.

Contact

We hope you enjoy HTGS and its functionality.
If you have any suggestions or comments please feel free to send us an email.

Get Connected