Open EthanAnderes opened 6 years ago
Hmm, I can reproduce your error, but this works fine:
julia> module Foo
using FFTW
end
Main.Foo
julia> Foo.fft([3,4,5])
3-element Array{Complex{Float64},1}:
12.0 + 0.0im
-1.5 + 0.8660254037844386im
-1.5 - 0.8660254037844386im
so it may be a problem with JuliaLang/julia#22763. Can we boil it down to a simpler test case?
(Not sure why you need @generated
here.)
Okay, here is a simpler test case:
julia> module Foo
using FFTW
foo() = plan_fft([0.0+0.0im], flags=FFTW.PATIENT)
end
Main.Foo
julia> Foo.foo()
WARNING: both FFTW and Base export "FFTW"; uses of it in module Foo must be qualified
ERROR: UndefVarError: FFTW not defined
Stacktrace:
[1] foo() at ./REPL[1]:3
And even simpler:
julia> module Foo
using FFTW
const foo = FFTW.PATIENT
end
WARNING: both FFTW and Base export "FFTW"; uses of it in module Foo must be qualified
ERROR: UndefVarError: FFTW not defined
Thanks for looking into it so quick @stevengj.
In response to your question "Not sure why you need at-generated here" ....
Basically, I'm working with multiple fields that can be defined on different grids (encoded by Flat{Θpix,nside}
). The beauty of the generated version is that I can write methods which don't require me to keep track and pass planned fft's to my methods. E.g. most of my code has the form
function foo(f::Field{P,T}) where {P<:Flat, T<:Real}
g = r𝔽(P,T)
... then do stuff with g and f, etc .
end
The first time foo
gets called on a field with a new grid geometry P<:Flat
, a new plan is generated. Subsequent calls to g = r𝔽(P,T)
are instantious. It also gives me access to grid geometry stuff in the body of the methods that don't need to be passed or pre-computed.
Also, I believe (though untested as of yet) that this works well when parallelizing across multiple machines (all of which should be generating their own plan for the architecture, I think).
It's really amazing having this generated stuff!
I see. Note that you can just use Array{T}(nside,nside)
instead of rand(T,nside,nside)
, since the FFTW.PATIENT
planner re-initializes the array anyway.
I believe the original workaround for this was to use importall FFTW
, but importall
is now deprecated in 0.7.
Been trying to get some code running on v0.7 and running into difficulties with getting FFTW to work in my modules. Here is a simplified module that gives me errors.
I want the following code block to run ...
.... but I get the following error in the line:
Any ideas what is going on?
Here is my version info: