co_reduce
コマンドの標準例(https://gcc.gnu.org/onlinedocs/gfortran/CO_005fREDUCE.html#CO_005fREDUCE)は動作していないようです。 np
プロセッサを使用してこの例を実行すると、Product value
がnp
!と返されます。最初の画像の値は一見ランダムな方法で破損している:np = 4
とco_reduceを使用したFortranコアアレイ
18:10 rditldmt $ caf co_reduce_example.f08 -o co_reduce_example
18:10 rditldmt $ cafrun -np 4 ./co_reduce_example
Number of images = 4
value [ 1 ] is 1690042368
value [ 2 ] is 2
value [ 3 ] is 3
value [ 4 ] is 4
Product value = 1690042368
Expected value = num_images()!
2! = 2, 3! = 6, 4! = 24, ...
、予想回答= 24。計算の答え= 1690042368.
Anは例のバージョンをインストルメント、co_reduce_example.f08
は、次のとおりです。
program co_reduce_example
implicit none
integer :: value[ * ]
integer :: k
value = this_image ()
call co_reduce (value, result_image = 1, operator = myProd)
if (this_image () == 1) then
write (* , '("Number of images = ", g0)') num_images ()
do k = 1, num_images ()
write (* , '(2(a, i0))') 'value [ ', k, ' ] is ', value [ k ]
end do
write (* , '("Product value = ", g0)') value ! prints num_images() factorial
write (* , 100)
end if
100 format ("Expected value = num_images()!", /, " 2! = 2, 3! = 6, 4! = 24, ...")
contains
pure function myProd (a, b) result (rslt)
integer, value :: a, b
integer :: rslt
rslt = a * b
end function myProd
end program co_reduce_example
がどのようにコードを修正しますか?
Co-ArrayのFortranのバージョン:
17:50 rditldmt $ cafrun -v
OpenCoarrays Coarray Fortran Executable Launcher (caf version 1.3.6)
Copyright (C) 2015-2016 Sourcery, Inc.
OpenCoarrays comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of OpenCoarrays under the terms of the
BSD 3-Clause License. For more information about these matters, see
the file named LICENSE.
のgfortranバージョン:
17:54 rditldmt $ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin15/6.0.0/lto-wrapper
Target: x86_64-apple-darwin15
Configured with: /opt/local/var/macports/build/_opt_mports_dports_lang_gcc6/gcc6/work/gcc-6-20160327/configure --prefix=/opt/local --build=x86_64-apple-darwin15 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc6 --includedir=/opt/local/include/gcc6 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-6 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-6 --with-gxx-include-dir=/opt/local/include/gcc6/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc6 6-20160327_0'
Thread model: posix
gcc version 6.0.0 20160327 (experimental) (MacPorts gcc6 6-20160327_0)
出血の端をテストしています。 Crayコンパイラでさえこれをサポートしていません。 OpenCoarrayとgfortranの実装にバグがあったとしても驚くことはありません。おそらく、https://github.com/sourceryinstitute/opencoarrays/issuesで問題を開くべきであり、あなたが得ることができる最も知識のある人からの回答を得る可能性が非常に高いです。 –
@VladimirF:いい考えです。 https://github.com/sourceryinstitute/opencoarrays/issues/172 – dantopa