在windows上使用cmake编译FFTW(OpenMP)
Compiling FFTW (OpenMP) with cmake on windows
我正试图在我的windows机器上安装带有cmake的FFTW。我下载了最新版本的源文件,并首先使用以下选项运行cmake:
mkdir build && cd build
cmake --DBUILD_TESTS=False -DENABLE_FLOAT=On ..
cmake --build . --config Release
这在Visual Studio 2017和2019上都很好。然而,当我尝试用OpenMP编译代码时,
cmake --DBUILD_TESTS=False -DENABLE_FLOAT=On -DENABLE_OPENMP=On ..
cmake --build . --config Release
我收到一大堆链接错误:
[...]
ct.obj : error LNK2001: unresolved external symbol fftwf_ops_zero [C:Usersjha1Desktopfftw-3.3.8.tarfftw-3.3.8buildfftw3f_omp.vcxproj]
dft-vrank-geq1.obj : error LNK2001: unresolved external symbol fftwf_ops_zero [C:Usersjha1Desktopfftw-3.3.8.tarfftw-3.3.8buildfftw3f_omp.vcxproj]
hc2hc.obj : error LNK2001: unresolved external symbol fftwf_ops_zero [C:Usersjha1Desktopfftw-3.3.8.tarfftw-3.3.8buildfftw3f_omp.vcxproj]
[...]
然而,看起来cmake能够在配置阶段找到OpenMP,所以我不确定是什么导致了这个问题。
[...]
-- Found OpenMP_C: -openmp (found version "2.0")
-- Found OpenMP_CXX: -openmp (found version "2.0")
-- Found OpenMP: TRUE (found version "2.0")
[...]
注意,这在我的带有gcc9的linux机器上运行得很好。
我能够使用MinGW-W64在MSYS2中使用configure
在不同版本中构建fftw-3.3.8(版本http://winlibs.com)像这样:
INSTALLPREFIX=/usr/local
BUILDPLATFORM=i686-w64-mingw32
RUNPLATFORM=i686-w64-mingw32
BUILDPLATFORM=x86_64-w64-mingw32
RUNPLATFORM=x86_64-w64-mingw32
mkdir -p build_single build_longdouble build_quad build_standard &&
cd build_single &&
#../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --with-our-malloc16 --enable-threads --with-combined-threads --enable-portable-binary --enable-sse2 LDFLAGS="-Wl,--enable-auto-import" &&
#../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-single --enable-sse --enable-sse2 --enable-avx LDFLAGS="-Wl,--enable-auto-import" &&
../configure --cache-file=../config.cache --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-single --enable-sse --enable-sse2 --enable-avx LDFLAGS="-Wl,--enable-auto-import" &&
cd .. &&
cd build_longdouble &&
#../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-long-double LDFLAGS="-Wl,--enable-auto-import" &&
../configure --cache-file=../config.cache --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-long-double LDFLAGS="-Wl,--enable-auto-import" &&
cd .. &&
#cd build_quad &&
##../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-quad-precision LDFLAGS="-Wl,--enable-auto-import" &&
#../configure --cache-file=../config.cache --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-quad-precision LDFLAGS="-Wl,--enable-auto-import" &&
## fix building DLLs
#mv libtool libtool.bak &&
#sed -e "s/(allow_undefined=)yes/1no/" libtool.bak > libtool &&
#cd .. &&
cd build_standard &&
#../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-sse2 --enable-avx LDFLAGS="-Wl,--enable-auto-import" &&
../configure --cache-file=../config.cache --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-sse2 --enable-avx LDFLAGS="-Wl,--enable-auto-import" &&
cd .. &&
( make -Cbuild_single || make -Cbuild_single LIBS="-lpthread" ) &&
make -Cbuild_single install-strip &&
( make -Cbuild_longdouble || make -Cbuild_longdouble LIBS="-lpthread" ) &&
make -Cbuild_longdouble install-strip &&
#( make -Cbuild_quad || make -Cbuild_quad LIBS="-lpthread" ) &&
#make -Cbuild_quad install-strip &&
( make -Cbuild_standard || make -Cbuild_standard LIBS="-lpthread" ) &&
make -Cbuild_standard install-strip &&
# fix absolute link in .cmake file(s)
sed -i -e "s?$(echo $INSTALLPREFIX|sed -e "s?^/([a-zA-Z])/?1:/?")?${CMAKE_CURRENT_LIST_FILE}/../../../..?g" $INSTALLPREFIX/lib/cmake/fftw3/*Config.cmake &&
echo Done
如果你不想要所有这些版本,你可以坚持使用与build_standard
相关的行。
没有像这样构建的OpenMP问题。
相关文章:
- OpenMP阵列性能较差
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- OpenMP:并行更新数组总是需要减少数组吗
- 如何使用OpenMP并行这两个循环
- 从python调用openMP共享库时,未定义opnMP函数
- 如何使用OpenMP并行化此矩阵时间矢量运算
- 如何使用OpenMP使这个循环并行
- 在 Mac 上使用 CMAKE 将 FFTW 和 FFTWPP 链接到项目中时未定义的符号
- 如何通过替换顺序代码的while循环来添加OpenMP for循环
- 查找最近配对时的OpenMP竞赛条件
- 使用输入打破 OpenMP 中的循环
- 为什么 openmp 的并行不适用于矢量化色彩空间转换?
- 在 openmp 中,omp_get_thread_num是否绑定到物理线程?
- 在C++中使用并行化的预期速度是多少(不是 OpenMp,而是 <thread>)
- OpenMP 加上unordered_map<字符串、双字符串的缩减>
- OpenMP 与有序和关键指令并行
- 我使用 OpenMP 的线程越多,执行时间就越长,这是怎么回事?
- 在windows上使用cmake编译FFTW(OpenMP)
- 使用OpenMP创建FFTW计划