program scatter_with_HPF USE HPF_LIBRARY USE HPF_LOCAL_LIBRARY integer xmax,ymax,totelem parameter (xmax=1000,ymax=1000) parameter(niters=1) parameter (totelem=xmax*ymax) double precision ,dimension(xmax,ymax) :: A,base double precision,dimension(totelem) ::dindex1,dindex2 integer,dimension(totelem) :: index1,index2 double precision V(totelem) double precision time_begin,time_end !HPF$ DISTRIBUTE (BLOCK,BLOCK) :: A !HPF$ DISTRIBUTE (BLOCK) :: index1,index2,dindex1,dindex2 !think that scattered vector V is stored into temp 2-d buffer call random_number(V) call random_number(dindex1) call random_number(dindex2) index1 = xmax*dindex1 + 1 index2 = ymax*dindex2 + 1 time_beg = elapsed_time() !HPF$ independent,new(i,i1,i2) do i=1,totelem i1 = index1(i) i2 = index2(i) A(i1,i2) = V(i) enddo !A = copy_scatter(temp,base,index1,index1,mask) print *,'Elapsed time for ',niters,' iterations for scatter ' print *,'with HPF For matrix with dimensions',xmax,ymax ,' is' print *,elapsed_time() end !***************************************************** !***************************************************** real function elapsed_time() integer :: clock_count, clock_rate, clock_max integer, save :: last_count logical, save :: system_clock_not_yet_called = .true. call system_clock(count=clock_count,& count_rate=clock_rate, & count_max=clock_max) if (system_clock_not_yet_called) then system_clock_not_yet_called = .false. elapsed_time = 0.0 else if (clock_count > last_count) then elapsed_time = real(clock_count-last_count)/real(clock_rate) else elapsed_time = real(clock_max-last_count+clock_count)& /real(clock_rate) end if last_count = clock_count return end function elapsed_time subroutine timer(t) integer val(8) double precision t call date_and_time(values=val) t = dble(val(8))*1d-3 + dble(val(7)) + & dble(val(6))*60d0 + dble(val(5))*3600d0 end subroutine timer