Q:

Why single CPU core's performance on the same workload different in pthread and OpenCL?

I have a very simple task: scan over a char array multiple times (16*1024). I implemented it with pthread with one thread on one CPU core. The time is 23's. Then I use device fission to create a device containing only one CPU Compute Unit (i.e., one CPU core), the time is only 17's. In my opinion, the OpenCL implementation should be slower than pthread (because C is more hardware-close). How come I get this results?

A:

The OpenCL kernel language is very close to the hardware. It's a supersubset of C99 (subset as in no function pointers are supported and superset as in you have vector datatypes etc)
The implementations are generally built on top of llvm and the kernels compile to raw X86 functions. In addition due to nature of OpenCL the implementation can do a lot more optimizations than what full C compiler can do, such as way better support for autovectorization. Thus it's not a surprise at all that a code written as OpenCL kernel can easily outperform a naive loop version of the same. One has to do a lot of work to get it approach the OpenCL version.
Currently especially the Intel CPU OpenCL implementation is mostly a marvelous way to write parallel CPU code. Even though in your case you limited it to just single core it's almost certain that it used the full extent of available vector instructions for X86.

