Compiler parallelization in visual studio

Compiler parallelization in visual studio

Hi,

I am very new to visual fortran and I have my intel fortran compiler setup with visual studio. One of the feature that I read was the compiler can provide with parallelization and auto-parallelization is one of the techniques. For eg the sample code:

    program HelloWorld

    implicit none

    ! Variables
    INTEGER :: istat,i,j,k,m;
    real :: start,finish;
    ! Body of HelloWorld
    call cpu_time(start)
    print *, 'Hello World'
    do i = 1, 50000000
         j = j + 1
         do k=1,100
            m = m+1
         end do
      end do
    call cpu_time(finish)
    print '("Time = ",f," seconds.")',finish-start
    end program HelloWorld

Yes, every iteration my data is independant of the iteration (not very clear in the example though). What is my best option and how do I configure the compiler to do so in VS2008. The compiler version I am using is Intel(R) Visual Fortran 11.1.051 [IA-32]

Thanks

AJ

6 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

You may need a more realistic case which doesn't lend itself to shortcutting to illustrate your point.  The compiler is more likely to figure out the final values of i,j,k,m than to find a way to calculate in parallel.  Assuming you mean to have the i loop divided among cores or hyperthreads, and intend to add some calculation depending on j and m, you need to make j and the starting values of m depend explicitly on i so that each thread can work with its own copy of those variables.

You would expect cpu_time timing result to increase with number of threads, as it requests a total of the time spent among the threads.  You could also collect elapsed time by system_clock and take the ratio to get a measure of concurrency.  As these functions work with a tick rate such 64/sec, you will expect to measure zero time beyond what print requires, if there is any shortcutting.

Thanks Tim for your reply.

Yes, the example is pretty unrealistic but simply put I have 

 do i = 1, 50000000
      Operations on value of i and independent of each iteration

I need to divide the i loop into the cores. I just tried replacing the do with do concurrent but the compiler throws an error. Any reason why this should happen? I am using Intel(R) Visual Fortran 11.1.051  compiler.

Thanks

Ajay

do concurrent invites the compiler to diagnose whether you made data independent among iterations.  This doesn't mean the compiler will figure out how; it means you must make data explicitly independent.

The explanation in the ifort manual is a little more complete than typical ones, but still remains somewhat technical.

Thank you for your reply, I am getting the hang of things slowly. My machine is preinstalled with intel fortran on Visual Studio, can you please point me in any direction that would help me with beginning with open mp on intel visual fortran with visual studio? 

i tried simple codes like this:

 

program OpenMP
implicit none

INTEGER THREADS , ID
!$OMP PARALLEL
threads = omp_get_num_threads()
id = omp_get_thread_num()
PRINT *, "NUM THREADS:", THREADS
PRINT *, "hello from thread:",id," out of", threads 
!$OMP PARALLEL END
STOP

end program OpenMP

I tried compiling this after Enabling the "process parallel code" in visual studio for processing openmp directives. But this throws me errors during compilation saying it does not recognize the thread and id functions. Also throws an error at the parallel end function

" found 'END' when expecting one of: DO SECTIONS WORKSHARE PRIVATE FIRSTPRIVATE REDUCTION COPYIN NUM_THREADS SHARED IF "

I am sorry if the question seems to be going out of context, but any help or any pointers in the right direction would be really appreciated !

Many thanks for your insights
Ajay
 

I have got the mistakes that I was commiting in the above code, its !$OMP END PARALLEL and not !$OMP PARALLEL END.

Also I need to use omp_lib.

Thanks

Ajay

Accedere per lasciare un commento.