This content requires the Adobe Flash Player and a browser with JavaScript enabled. Click here to get the latest version of Adobe Flash Player.

Design style suits C to parallelisation

First stage towards standardisation of C for multi-processor systems

EDN Europe, 10 Apr 2008

Belgian research centre IMEC has introduced a programming coding style for C code, called CleanC that increases the extent to which analysis tools can parallelise and optimise the code for multiprocessor target systems. IMEC is developing tools to efficiently distribute applications over multiple processorswhile taking care of synchronisation of tasks and exchange of data between tasks. The tool flow will consist of parallelisation and memory hierarchy optimisations tools: to allow them to comprehend the application code, a number of restrictions are imposed on coding in ANSI-C. CleanC is sequential code in what IMEC calls a multiprocessor-friendly way.
IMEC’s VP of nomadic embedded systems, Rudy Lauwereins, observes that in regular C, parallelism is “hidden”; automatic tools cannot infer or extract parallel behaviour or tasks. In an ideal world, Lauwereins says, you would code everything in a different language that had the necessary structures to make parallelism explicit. But coders are not going to abandon C: and, there is a vast amount of legacy C that might be modified for multiprocessor environments, but that no-one is ever going to re-code.
Therefore; make the C fit the task. It turns out, says Lauwereins, that there is a finite number of coding guidelines that will do the job; unfortunately, that number is 29. “Most are just good coding style,” Lauwereins says, “but some do represent a restriction compared to the way people have been used to writing C. Some are already well-known; for example, not using pointers. But there is no way around it – if you want to work in C and you want parallelisable code, then you must accept the restrictions.” IMEC has therefore written a set of analysis plug-ins, available free through Eclipse that will check code for adherence to the 29 rules. (Find them here)
A natural follow-on question is, can software automatically re-code – refactor is the trm IMEC uses – C to comply. The answer, Lauwereins say, is yes; but it is difficult. So far has the organisation has done it for only three of the 28 cases, and even when complete, it will not be a totally automatic process. But once code has passed that filter, you will be able to apply it to a set of downstream tools that will implement the CleanC for a multicore environment – beginning with eliminating caches and the coherency problems that accompany them. The steps of this part of the process will also require manual intervention, Lauwereins, says, writing parallel directives to the compiler – but the result will be an efficiently-distributed design. IMEC’s intention is to present CleanC as a candidate for formal standardisation.


 

Our Sponsors



Ads by Google