我正在使用gfortran编译器并尝试在没有MPI的情况下进行并行编程。虽然我花了太多时间阅读Fortran,gfortran,并行编程,但我无法同时使用不同的处理器。
我的目的是创建一个矩阵乘法,在不同的处理器上工作,以减少时间。我有很多想法,但首先,我必须使用不同的处理器。但即使我使用书面代码,我的电脑只有一个图像。例如:
program hello_image
integer::a
write(*,*) "Hello from image ", this_image(), &
"out of ", num_images()," total images"
read(*,*), a
end program hello_image
这是一个非常简单的程序,摘自关于Fortran并行编程的pdf。它应该给出输出:
Hello from image 1 out of 8
Hello from image 2 out of 8
Hello from image 3 out of 8
Hello from image 4 out of 8
Hello from image 5 out of 8
Hello from image 6 out of 8
Hello from image 7 out of 8
Hello from image 8 out of 8
但我的编译器只是提供输出:
Hello from image 1 out of 1.
我使用命令
将gfortran用作编译器gfortran "codename" -fcoarray=single
我花了太多时间来解决这个问题"可能是简单的问题"但我无法解决它。
这是我尝试-fcoarray = lib时得到的输出。这就是我使用-fcoarray = single的原因,因为它是唯一可以执行的。我该怎么做才能解决这个问题?谢谢你的帮助;
/tmp/ccvnPvRc.o: In function `MAIN__':
hew.f08:(.text+0x62): undefined reference to `_gfortran_caf_this_image'
hew.f08:(.text+0xa8): undefined reference to `_gfortran_caf_num_images'
/tmp/ccvnPvRc.o: In function `main':
hew.f08:(.text+0x175): undefined reference to `_gfortran_caf_init'
hew.f08:(.text+0x19f): undefined reference to `_gfortran_caf_finalize'
collect2: error: ld returned 1 exit status
尽管我从OpenCoarrays网站安装了linuxbrew,但仍有同样的问题。 brew医生说没有问题,但是当我使用这条线时
gfortran hew.f08 -fcoarray=lib -lcaf_mpi
出现相同的错误。我应该在另一条线上使用另一个套餐吗?我应该下载什么包?如何下载?如何使用gfortran获得可执行文件? (我使用的是Ubuntu)
我用过
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"
要安装的行。然后,我使用两条线来设置路径;
PATH=/home/[username]/.linuxbrew/bin:$PATH
PATH=/home/linuxbrew/.linuxbrew/bin:$PATH
现在,当我使用
行时gfortran hew.f08 -fcoarray=lib -lcaf_mpi
输出结果为:
/usr/bin/ld: cannot find -lcaf_mpi
collect2: error: ld returned 1 exit status