2 weeks ago I helped a client start using the Intel Ct Beta. At the same time, as usual, I myself figured out a little, and now I want to share.
Recently there was an opportunity to download beta Ct, registering on the
site . So far only for Windows, but after a while there should be a beta for Linux.
If you carefully read the article on Intel Ct in
Wikipedia ... then you will not be able to find out anything about the essence of Ct. In Russian, too, a little information. And it is a pity - technology from a number of those that personally seem to me both useful and elegant.
If one sentence is, Intel Ct is a technology that allows a programmer to use the parallelism of modern and advanced hardware, in many of its forms, quite transparently. The landscape is quite well-rounded - CUDA, OpenCL, Cilk ++, TBB, OpenMP, MPI, etc. Each approach has its own scope, strengths and weaknesses, its supporters and their own directions of development. The scope of Ct - the implementation of data parallel algorithms. So from the above list of tasks to Ct are the most close to CUDA and OpenCL.
')
I would call Ct DSL. There is a runtime implemented in C ++ (templates, operator overloading, everything is very ideal). Naturally, the Ct program will be compiled by the Intel compiler. The last gcc will work too.
The main type is Vec. Its immutable instances are passed by value, and operators return a new instance. Hence, a functional flavor, and significant advantages in providing multi-thread correctness. No problems with data-races and deadlocks (by design).
Vec are different - one-dimensional, 2-nd and 3-dimensional, sparse. Their elements can be different types, including vectors. For example,
Vec charArray (source, width); // create and initialize vector
Vec2D intArray (source, width, height);
rcall (ct_foo) (charArray, 1); // call example Ct code.
The program is divided into 2 areas - the C ++ area and the Ct area. It is possible in the same .cpp file. In the C ++ area, you can declare and initialize vectors, and in the Ct area, you can perform operations on them. For example, the code above is the C ++ domain. (I simplify a little here.)
Here is the Ct area:
void ct_foo (Vec & charArray, int t)
{
charArray + = t; // updates all vector data with scalar.
}
Less trivial examples can be found in the samples directory or
here .
There are two types of compilation - debug and release. The main difference is linking with different libraries. After linking with the debugging library, everything will work transparently in the Intel Debugger (and in gdb, of course, too), you can debug as usual C ++ code.
The release version is linked with its runtime (there is actually a virtual machine - there is a GC, JIT). During its launch, recompilation occurs for the architecture on which it is executed. Rather fast recompilation. Even in beta, this is not a very long process - I measured about 300 milliseconds for the average size of the calculation task.
What is the benefit of such a relatively complex internal architecture? And how else can you ensure upward compatibility for the developer?
For example, if suddenly sometime :) there will be processors consisting of several “wide” x86 cores and a large number of simple x86 cores sitting on a common memory. Or it will be necessary to use SIMD and multi-core at the same time. And if heterogeneous cores are a matter of the rather distant future, the expansion of SIMD registers to 256 bits will happen
soon . And there, you see, and 512 bits just around the corner. And the recompilation is not required - just link to the dynamic library. Well, that with runtime.
The code in Ct expresses the algorithm from the point of view of the computational problem, quite transparently relative to the platforms on which it can be executed. Rantaym understands the platform, and there is no need to change the implementation or worry about blocks / warps / threads.
Since the product has not yet been officially released, I cannot describe the functionality in great detail - it will change anyway. But it is hardly radical, and, most likely, if this happens, scripts / documents will be available that will help to adapt the written software to the release. If you download the beta now, then in the Doc directory there is a wonderful file ct_userguide.pdf. Everything's there. This time our technical writers did a particularly good job. Of course, everything is not in our language, but who did it stop? Even more information will appear closer to the release, well, I can answer some questions in the comments.
It was difficult to write so many letters without ever mentioning one product logically related to the subject area. It is not far in the lab here, but alas, until I can say anything new about it.