Re: [f2py] compiling extension using openmp

Zhenfei Yuan <[email protected]> Wed, 28 Nov 2012 12:20:57 +0800
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============6339253898388365114==
Content-Type: multipart/alternative;
 boundary="------------030202070901070103040504"

This is a multi-part message in MIME format.
--------------030202070901070103040504
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi, all

      I'm now wrapping some fortran codes into python using f2py and for 
performance sake, I use some fortran openmp directive sentences. It work 
well when I uses the command "f2py --f90flags='-fopenmp' -c xxx.pyf 
xxx.f90 -lgomp" to obtain the extension module. however when I writes  a 
setup.py file and add the extension in this file, I found only one 
thread is working.

      The sentence that adds an extension of f2py module into setup.py 
is as below

     "
     config.add_extension(
         name="wrapper",
         sources=['xxx.f90','xxx.pyf'],
         libraries=['gomp'],
         extra_compile_args=['-fopenmp'],
         extra_link_args = []
         )
     "

      I find the mail two years ago, " 
http://cens.ioc.ee/pipermail/f2py-users/2010-September/002080.html", 
also the wiki created by Paul that summaries 
"http://www.scipy.org/Dynetrekk/f2py_OpenMP_draft ".

      Openmp in the draft works but mine doesn't work, is that because:

    1)  it uses Makefile to tell fortran compiler to use openmp via
    "f90flags=-fopenmp", rather than typing "python setup.py build"
    command  only;

         2)  the "extra_compile_args=['-fopenmp']" isn't functioning?

     Best regards,

     Jeffrey Yuan




--------------030202070901070103040504
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi, all<br>
      <br>
    </div>
    &nbsp;&nbsp;&nbsp;&nbsp; I'm now wrapping some fortran codes into python using f2py and
    for performance sake, I use some fortran openmp directive sentences.
    It work well when I uses the command "f2py --f90flags='-fopenmp' -c
    xxx.pyf xxx.f90 -lgomp" to obtain the extension module. however when
    I writes&nbsp; a setup.py file and add the extension in this file, I
    found only one thread is working.<br>
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp; The sentence that adds an extension of f2py module into
    setup.py is as below
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <br>
    <br>
    &nbsp;&nbsp;&nbsp; "<br>
    &nbsp;&nbsp;&nbsp; config.add_extension(<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="wrapper",<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sources=['xxx.f90','xxx.pyf'],<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; libraries=['gomp'],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extra_compile_args=['-fopenmp'],<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extra_link_args = []<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>
    &nbsp;&nbsp;&nbsp; "<br>
    <br>
    &nbsp; &nbsp;&nbsp; I find the mail two years ago, "
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <a moz-do-not-send="true"
href="http://cens.ioc.ee/pipermail/f2py-users/2010-September/002080.html">http://cens.ioc.ee/pipermail/f2py-users/2010-September/002080.html</a>",

    also the wiki created by Paul that summaries "<a
      moz-do-not-send="true"
      href="http://www.scipy.org/Dynetrekk/f2py_OpenMP_draft">http://www.scipy.org/Dynetrekk/f2py_OpenMP_draft</a>
    ". <br>
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp; Openmp in the draft works but mine doesn't work, is that
    because:&nbsp; <br>
    <br>
    <blockquote>1)&nbsp; it uses Makefile to tell fortran compiler to use
      openmp via "f90flags=-fopenmp", rather than typing "python
      setup.py build" command&nbsp; only; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>
    </blockquote>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2)&nbsp; the "extra_compile_args=['-fopenmp']" isn't functioning?<br>
    <br>
    &nbsp;&nbsp;&nbsp; Best regards,<br>
    <br>
    &nbsp;&nbsp;&nbsp; Jeffrey Yuan<br>
    <br>
    <br>
    <br>
    <pre class="moz-signature" cols="72">
</pre>
  </body>
</html>

--------------030202070901070103040504--



--===============6339253898388365114==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users

--===============6339253898388365114==--