kokkos / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Note: the repository does not accept github pull requests at this moment. Please submit your patches at http://reviews.llvm.org.
http://llvm.org
Other
4 stars 2 forks source link

Ensure KOKKOS_FUNCTION on functions called in a parallel context #3

Closed calewis closed 4 years ago

calewis commented 4 years ago

This check will ensure that functions called inside Kokkos::parallel_* functors and functions annotated with KOKKOS_FUNCTION are annotated with KOKKOS_FUNCTION.

At a minimum should detect the calls to oops in both not_oops and the KOKKOS_LAMBDA, this check will be made significantly easier if new versions of Kokkos are required due to an annotation attribute added to KOKKOS_FUNCTION.

int oops(int x){ return x;}

KOKKOS_FUNCTION
int not_oops(int x){return oops(x);}

Kokkos::parallel_for(7, KOKKOS_LAMBA(int x){printf("%d", oops(x));});

Also we need to be sure not to flag functions such as printf

calewis commented 4 years ago

Need to make sure that nested lambdas don't trigger this warning since they don't need annotations

Example that currently triggers a warning when it shouldn't.

Kokkos::parallel_for(7, KOKKOS_LAMBA(int x){
     [&]{x;}()
});
calewis commented 4 years ago

It turns out that the issue wasn't the previous post, it was that Kokkos::parallel_for internally was generating a CallExpr to our lambda operator(). I fixed this by only inspecting FunctionDecls that are in user space.

calewis commented 4 years ago

The check is being PRd right now, new problems should just be filed as new bugs.