Parallelize with just one core?

Asked

Viewed 95 times

2

I want to parallelize an application, in this case a 'Cosine similarity' calculation, but the machine I am working on has only one core. Parallelizing this calculation with just one core will have some significant gain?

1 answer

3


As you yourself suspect, no, there will be no performance increase in this case.

If the machine has hyperthreading - i.e.: two "visible" colors but only one physical core in that case, it would depend on the CPU model - it would have to have two internal Fpus, and it would have to be done a good job of distributing the tasks for the overhead of parallelizing not getting above the minimum gain you could have there.

But here are other considerations: do you want to "parallelize", or do you want to "accelerate" your calculation? Parallelizing to learn how to do this is one thing. Just wanting more performance is another.

If you are using Python, and expressing operations in pure Python (and not using something like Numpy, which has code for numerical processing), your program may be 1000 to 10000 times slower than the same program running in native code.

If you instead of running your program in normal Python, use the Pypy - the "Python made in Python", which has a JIT mechanism, will have a gain of about 10 times in the performance of purely numerical code.

If you use the Cython - a super-set of Python that compiles the program for C, and allows you to define the types of your numerical data (so your numbers can be a native int64, rather than a Python int object), you can get very close to native performance (i.e., more than 1000 times faster).

That being said, it is possible to "parallelize" the code by leveraging the resources that modern Cpus have for numerical calculations even in a single kernel - that is, if you can write your code in a way that uses Intel’s AVX instructions, for example. (Breaking any module that lets you take advantage of this numerical parallelism of the CPU will also be using native numbers, offering many of the gains described above). One of the projects that seems to be active that does this is the Pyopencl - that can use Opencl to make use of your CPU’s advanced features or even use your graphics card.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.