Is there a way for a function to determine if it is executing on a program thread or on a cilk thread?
In our application is already threaded, but we are investigating using cilk to add greater parallelism. Our current system uses thread local storage to maintain a struct that contains the thread local portion of our memory manager. We currently have a function that is called to return the thread local struct. We'd like to use cilk to parallelize code that uses our memory manager, thus each strand would need access to one of these structs, so I'd like to extend our function to work when called on a strand. To make this work, I think I need to be able to differentiate between one of our threads and cilk thread. I'm ok with a strand executing on a program thread being treated either way.
I looked at Holders, but I don't think they will solve the problem completely. In particular, I still need to access the thread local struct from multiple program threads, so I need to know if a thread is a program thread or cilk thread. It is also not clear what happens when a holder is called from multiple program threads. I also looked at __cilkrts_get_worker_number, but the behaviour when called from program threads does not seem to be useful in my situation.