Skip to content

Add get_num_threads function#150

Closed
galenlynch wants to merge 1 commit intoJuliaMath:masterfrom
galenlynch:get_num_threads
Closed

Add get_num_threads function#150
galenlynch wants to merge 1 commit intoJuliaMath:masterfrom
galenlynch:get_num_threads

Conversation

@galenlynch
Copy link
Copy Markdown
Contributor

While it is possible to change the number of threads used by FFTW plans with
set_num_threads, it is impossible to see what the current value is. This is
made difficult because FFTW3 does not, as far as I know, provide a way to do
this. However, caching the last argument passed to set_num_threads as a
constant in FFTW.jl allows later access. I have added a constant,
PLAN_NUM_THREADS to keep track of the last argument to set_num_threads,
modified set_num_threads to update this constant, and added a function
get_num_threads to access the constant.

Closes #117

While it is possible to change the number of threads used by FFTW plans with
`set_num_threads`, it is impossible to see what the current value is. This is
made difficult because FFTW3 does not, as far as I know, provide a way to do
this. However, caching the last argument passed to `set_num_threads` as a
constant in FFTW.jl allows later access. I have added a constant,
`PLAN_NUM_THREADS` to keep track of the last argument to `set_num_threads`,
modified `set_num_threads` to update this constant, and added a function
`get_num_threads` to access the constant.
@stevengj
Copy link
Copy Markdown
Member

This is reasonable, but I would ideally like to fix this in the FFTW C library; otherwise in principle this could return the wrong result if a C library links to FFTW and changes this.

https://github.com/FFTW/fftw3/blob/516116615362334c2051a16ec1658a888573ab63/threads/api.c#L70-L81 is where a new function int X(planner_nthreads)(void) { return X(the_planner)()->nthr; } would go.

@galenlynch
Copy link
Copy Markdown
Contributor Author

I will attempt to add this to the FFTW C library instead of caching it in Julia (FFTW/fftw3#205).

@galenlynch galenlynch closed this Jun 19, 2020
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

Successfully merging this pull request may close these issues.

get version of FFTW.set_num_threads()?

2 participants