顯示具有 Parallel 標籤的文章。 顯示所有文章
顯示具有 Parallel 標籤的文章。 顯示所有文章

2011年9月21日 星期三

Using Parallelism in Python

1. Cython (C-Extensions for Python)
http://cython.org/
wget http://cython.org/release/Cython-0.15.tar.gz
tar zxf Cython-0.15.tar.gz
cd Cython-0.15
python setup.py install

2. Multi-threading (built-in)
import threading

3. Parallel Python
http://www.parallelpython.com/content/view/17/31/

4. python-multiprocessing
Python 2.5/2.4 back port of the multiprocessing package
http://code.google.com/p/python-multiprocessing/

[references]
Does python support multiprocessor/multicore programming?
Practical threaded programming with Python
Basic Threading in Python
Understanding Threading in Python
Simple Python: a job queue with threading

http://hungic.blogspot.com/2008/08/pythonthreading.html
http://www.cppblog.com/riverbird/archive/2007/12/26/39704.html

2011年1月3日 星期一

cout and printf in OpenMP

Many implementations of printf acquire a lock to ensure that each printf call is not interrupted by other threads.

In contrast, std::cout's overloaded << operator means that (even with a lock) one thread's printing of i and ' ' and '\n' can be interleaved with another thread's output, because std::cout << i << " " << endl; is translated to three operator<<() function calls by the C++ compiler.

[References]
http://stackoverflow.com/questions/4459888/openmp-c-and-c-cout-printf-does-not-give-the-same-output
http://berenger.eu/blog/2010/12/06/c-openmp-stdcout-print-with-openmp/