Hi,
I am trying to write a custom tasking layer in Chapel that uses our ATMI
runtime (tasking layer on top of AMD's ROCm runtime stack); one of the use
cases being able to re-implement the Futures package using ATMI. Eventually, I
want to be able to translate Futures.async to atmi_task_launch and translate
Futures.andThen to atmi_task_launch with the dependent tasks as arguments. ATMI
is better equipped to build task graphs, and hence this exploration.
extern proc chpl_task_launch(fn: c_fn_ptr, num_args: int, args_sizes: []
int(64), args...?numvals);
proc async(taskFn, args...) {
var f: Future;
//get fn ptr to taskFn, which itself can be taking variable arguments
//get fn args list
f = chpl_task_launch(c_ptrTo(taskFn), n, sizes, (...args));
return f;
}
To this end, I would need to pass custom Chapel procedures and lambdas as
{function id, arg1, arg2, ...} to the ATMI C runtime layer. How can I use the
existing Chapel-to-C interop to do the following:
1) Pass a user-written proc/lambda with any number arguments.
2) Pass the incoming variadic arguments as an argument region or any other
way in which it can be retrieved by the runtime.
It would have been easier if there was a C++ interoperability layer to Chapel,
but we only have a C interoperability layer for now, so we will have to make do
with that. Right now, I am trying to get to the above in a somewhat convoluted
way like this:
pragma "no doc"
proc getArgs(arg) {
return (arg,);
}
pragma "no doc"
proc getArgs(arg, args...) {
return (arg, (...getArgs((...args))));
}
extern proc chpl_task_launch(fn: c_fn_ptr, num_args: int, args_sizes: []
int(64), args: c_void_ptr); //args...?numvals);
proc async(taskFn, args...) {
var args_list = getArgs((...args));
var f = chpl_task_launch(c_ptrTo(taskFn), n, sizes, c_ptrTo(args_list));//
(...args));
return f;
}
But we are not sure if the above is the cleanest approach or if there are holes
in this approach. Any thoughts/suggestions?
Regards,
Ashwin
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers