OpenMP and Python

后端 未结 7 2094
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 23:03

I have experience in coding OpenMP for Shared Memory machines (in both C and FORTRAN) to carry out simple tasks like matrix addition, multiplication etc. (Just to see how it

7条回答
  •  执笔经年
    2020-11-28 23:35

    There is a package called pymp, which the author described it as a package that brings OpenMP-like functionality to Python. I have tried using it, but with different use case: file processing. It worked. I think it is quite simple to use. Below is a sample taken from the GitHub page:

    import pymp
    ex_array = pymp.shared.array((100,), dtype='uint8')
    with pymp.Parallel(4) as p:
        for index in p.range(0, 100):
            ex_array[index] = 1
            # The parallel print function takes care of asynchronous output.
            p.print('Yay! {} done!'.format(index))
    

提交回复
热议问题