Fortranでドットプロダクトを作成する必要があります。 Fortranの組み込み関数dot_product
を使用するか、OpenBLASのddot
を使用します。問題はddot
が遅いことです。これは私のコードです:BLASでOpenBLASは組み込み関数よりも遅いdot_product
:
dot_product
program VectorModule
! time VectorModule.e = 0.19s
implicit none
double precision, dimension (3) :: b
double precision :: result
integer, parameter :: LargeInt_K = selected_int_kind (18)
integer (kind=LargeInt_K) :: I
DO I = 1, 10000000
b(:) = 3
result = dot_product(b, b)
END DO
end program VectorModule
で
program VectorBLAS
! time VectorBlas.e = 0.30s
implicit none
double precision, dimension(3) :: b
double precision :: result
double precision, external :: ddot
integer, parameter :: LargeInt_K = selected_int_kind (18)
integer (kind=LargeInt_K) :: I
DO I = 1, 10000000
b(:) = 3
result = ddot(3, b, 1, b, 1)
END DO
end program VectorBLAS
2つのコードを使用してコンパイルされています。私は間違って
gfortran file_name.f90 -lblas -o file_name.e
何をしているのですか? BLASは高速である必要はありませんか?
http://stackoverflow.com/questions/35926940//36035152#36035152 –