I would like to vectorize this code below (just for an example), just assume somehow I should write an array inside an array.
PROGRAM TEST IMPLICIT NONE REAL, DIMENSION(2000):: A,B,C !100000 INTEGER, DIMENSION(2000):: E REAL(KIND=8):: TIME1,TIME2 INTEGER::I DO I=1, 2000 !Actually only this loop could be vectorized B(I)=100.00 !by the compiler C(I)=200.00 E(I)=I END DO !Computing computer's running time (start) CALL CPU_TIME (TIME1) DO I=1, 2000 !This is the problem, somehow I should put A(E(I))=B(E(I))*C(E(I)) !an integer array E(I) inside an array END DO !I would like to vectorize this loop also, but it didn't work PRINT *, 'Results =', A(2000) PRINT *, '' !Computing computer's running time (finish) CALL CPU_TIME (TIME2) PRINT *, 'Elapsed real time = ', TIME2-TIME1, 'second(s)' END PROGRAM TEST
I thought at first time, that compiler could understand what I want which somehow be vectorized like this:
DO I=1, 2000, 4 !Unrolled 4 times for example A(E(I))=B(E(I))*C(E(I)) A(E(I+1))=B(E(I+1))*C(E(I+1)) A(E(I+2))=B(E(I+2))*C(E(I+2)) A(E(I+3))=B(E(I+3))*C(E(I+3)) END DO
but I was wrong. Do you have any idea how I could vectorize it? Or can't it be vectorized at all? Thanks in advance.
Thread Topic:
Question