Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTG task migration #114

Open
josephjohnjj opened this issue Jun 18, 2021 · 1 comment
Open

TTG task migration #114

josephjohnjj opened this issue Jun 18, 2021 · 1 comment

Comments

@josephjohnjj
Copy link

I am trying to migrate a TTG task to another process. To do this, migrate() calls migrate_data() for each input data index of the task.

    void migrate(parsec_task_t* parsec_task, int dst )
    {
      int nb_input = parsec_task->task_class->dependencies_goal;

      if constexpr (!ttg::meta::is_void_v<keyT> )
      {
        keyT key;
        unpack(key, parsec_task->ttg_key, 0);
      
        for(int i = 0; i < nb_input; i++)
          migrate_data(i, key, parsec_task, dst);
        
        auto &world_impl = world.impl();
        world_impl.taskpool()->tdm.module->taskpool_addto_nb_tasks(world_impl.taskpool(), -1);
      }
      
    }


    template <typename Key>
    void migrate_data(int data_index, const Key &key, parsec_task_t* parsec_task, int dst )
    {
        using valueT = typename std::tuple_element<data_index, input_terminals_type>::type::value_type;

        parsec_data_copy_t *copy;
        copy = parsec_task->data[data_index].data_in;
        auto data = copy->device_private;

        using decvalueT = std::decay_t<valueT>;
        decvalueT val;
        pack(val, data, 0);

        set_arg_impl<data_index>(key, std::move(val), dst);
    }

To get the type of data to use pack() I used

using valueT = typename std::tuple_element<data_index, input_terminals_type>::type::value_type;

But when I do this I get an error:

ttg/ttg/ttg/parsec/ttg.h:568:84: error: ‘data_index’ is not a constant expression
  568 |         using valueT = typename std::tuple_element<data_index, input_terminals_type>::type::value_type;

Is there a way to overcome this?

@devreal
Copy link
Contributor

devreal commented Jun 18, 2021

The problem is that the argument to tuple_element has to be a compile-time constant. Try something like this:

    template <typename Key, int data_index>
    void migrate_data(const Key &key, parsec_task_t* parsec_task, int dst )
    {
        using valueT = typename std::tuple_element<data_index, input_terminals_type>::type::value_type;
        ...
    }

You can then recursively iterate over the std::tuple_size_v<input_terminals_type> using make_integer_sequence. For an example, check out register_input_callbacks in the PaRSEC ttg backend :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants