OpenCilk / opencilk-project

Monorepo for the OpenCilk compiler. Forked from llvm/llvm-project and based on Tapir/LLVM.
Other
93 stars 29 forks source link

Getting the number of workers used by opencilk #159

Closed yiansu closed 1 year ago

yiansu commented 1 year ago

I'm writing a manually optimized program using opencilk and need to know the number of threads used by the runtime.

I know how to set the number of worker threads used by opencilk through the environment variable CILK_NWORKERS=... However, does opencilk provide any facility/built-in function to get this number inside the program?

neboat commented 1 year ago

Yes, a program can get the number of Cilk workers by calling __cilkrts_get_nworkers(), which is declared in cilk/cilk_api.h.

Does that resolve your issue?

yiansu commented 1 year ago

Yes I'm able to extract the number of workers using that function. Thanks for the help!