1

I have a very simple cython code which use prange, which works fine in linux. However, when I try to do it in Windows. I encountered a problem that it can be compiled but cannot be imported:

ImportError: DLL load failed: This application has failed to start because the a
pplication configuration is incorrect. Reinstalling the application may fix this
problem.

Moreover, in windows I cannot from cython.parallel import threadlocal?! strange...

Is there anyone can point a direction?

System works fine: linux64, compiler gcc, packages: Python 2.7, cython 0.16

system has problem: Win64, compiler: MSVC VS2008, packages: Python 2.7, cython 0.16

Here is my simple cython pyx:

cimport cython
from cython.parallel import prange

def f(int n):
    cdef int i
    cdef int sum = 0
    for i in prange(n, nogil=True):
        sum += i
    print sum

Here is my setup.py:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np


setup(
    cmdclass = {'build_ext': build_ext},
    include_dirs = [np.get_include()], 
    ext_modules = [Extension("pcython1",  ["pcython1.pyx"],extra_compile_args=['/openmp',],),]
)
3
  • Does the code work fine under windows if prange is replaced by range? Commented Aug 3, 2012 at 7:02
  • @DaveP Thanks for your response! Without /openmp, both range and prange work. With it, neither of them works. Commented Aug 4, 2012 at 14:16
  • Turns out if the system has not installed the MS visual studio but only the VC++ redustributable, it works fine... Confused... And the CPU loads are completely different between range and prange version. So the openMP is working, just it cannot work on the system with the debug dlls installed, I guess. Commented Aug 4, 2012 at 15:06

2 Answers 2

1

Due to the VS2008 installer bug, the amd64_microsoft.vc90.openMP does not get installed into winSxS. Installing the openMP runtime will solve this problem.

see this question for detail: How to properly setup VS2008 for x64 programing?

Sign up to request clarification or add additional context in comments.

Comments

0

Use MinGW (see this question to properly setup mingw with cython) , then update your setup.py to:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np

ext_modules = [Extension("convolve_cy", ["convolve_cy.pyx"],
                         extra_compile_args = ["-O3", "-fopenmp"],
                         extra_link_args=["-fopenmp"])]

setup (
    name = 'performance test app',
    cmdclass = {'build_ext': build_ext},
    include_dirs = [np.get_include()],
    ext_modules = ext_modules,
)

This is working on a windows7 multi-core 64bit machine with Python 2.7 and cython 2.0.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.