Archive

Posts Tagged ‘compiler’

Assessing my predictions for 2009

January 24th, 2010 Derek-Jones No comments

I have been rather remiss in revisiting the predictions I made for 2009 to see how they fared. Only two out of the six predictions were sufficiently precise to enable an assessment one year later; the other four talking more about trends. What of these two predictions?

The LLVM project will die. Ok, the project is still going and at the end of December the compiler could build itself but the build is not yet in a state to self host (i.e., llvm compiler creates an executable of itself from its own source and this executable can build an executable from source that is identical to itself {modulo date/time stamps etc}). Self hosting is a major event and on some of the projects I have worked on it has been a contractual payment milestone.

Is llvm competition for gcc? While there might not be much commercial competition as such (would Apple be providing funding to gcc if it were not involved in llvm?), I’m sure that developers working on both projects want their respective compiler to be the better one. According to some llvm benchmarks they compile code twice as fast as gcc. If this performance difference holds up across lots of source how might the gcc folk respond? Is gcc compiler time performance an issue that developers care about or is quality of generated code more important? For me the latter is more important and I have not been able to find a reliable, recent, performance comparison. I understand that almost all gcc funding is targeted at code generation related development, so if compile time is an issue gcc may be in a hole.

I still don’t see the logic behind Apple funding this project and continue to think that this funding will be withdrawn sometime, perhaps I was just a year off. I do wish the llvm developers well and look forward to them celebrating a self hosted compiler.

Static analysis will go mainstream. Ok, I was overly optimistic here. There do not seem to have been any casualties in 2009 among the commercial vendors selling static analysis tools and the growth of PHP has resulted in a number of companies selling tools that scan for source security vulnerabilities (.e.g, SQL injection attacks).

I was hoping that the availability of Treehydra would spark the development of static analysis plugins for gcc. Perhaps the neatness of the idea blinded me to what I already knew; many developers dislike the warnings generated by the -Wall option and therefore might be expected to dislike any related kind of warning. One important usability issue is that Treehydra operates on the abstract syntax tree representation used internally by gcc, GIMPLE. Learning about this representation requires a big investment before a plugin developer becomes productive.

One tool that did experience a lot of growth in 2009 was Coccinelle, at least judged by the traffic on its mailing list. The Coccinelle developers continue to improve it and are responsive the questions. Don’t be put off by the low version number (currently 0.2), it is much better than most tools with larger version numbers.

Why does Intel sell compilers?

January 5th, 2010 Derek-Jones No comments

Intel is a commercial company and the obvious answer to the question of why it sells compilers is: to make money. Does a company that makes billions of dollars in profits really have any interest in making a few million, I’m guessing, from selling compilers? Of course not, Intel’s interest in compilers is as a means of helping them sell more hardware.

How can a compiler be used to increase computer hardware sales? One possibility is improved performance and another is customer perception of improved performance. My company’s first product was a code optimizer and I was always surprised by the number of customers who bought the product without ever performing any before/after timing benchmarks; I learned that engineers are seduced by the image of performance and only a few are ever forced to get involved in measuring it (having been backed into a corner because what they currently have is not good enough).

Intel are not the only company selling x86 chips, AMD and VIA have their own Intel compatible x86 chips. Intel compatible? Doesn’t that mean that programs compiled using the Intel compiler will execute just as quickly on the equivalent chip sold by competitors? Technically the answer is no, but the performance differences are likely to be small in most cases. However, I’m sure there are many developers who have been seduced by Intel’s marketing machine into believing that they need to purchase x86 chips from Intel to make sure they receive this ‘worthwhile’ benefit.

Where do manufacturer performance differences, for the same sequence of instructions, come from? They are caused by the often substantial internal architectural difference between the processors sold by different manufacturers, also Intel and its competitors are continually introducing new processor architectures and processors from the same company will have differences performance characteristics. It is possible for an optimizer to make use of information on different processor characteristics to tune the machine code generated for a particular high-level language construct, with the developer selecting the desired optimization target processor via compiler switches.

Optimizing code for one particular processor architecture is a specialist market. But let’s not forget all those customers who will be seduced by the image of performance and ignore details such as their programs being executed on a wide variety of architectures.

The quality of a compiler’s runtime library can have a significant impact on a program’s performance. The x86 instruction set has grown over time and large performance gains can be had by a library function that adapts to the instructions available on the processor it is currently executing on. The CPUID instruction provides all of the necessary information.

As well as providing information on the kind of processor and its architectural features the CPUID instruction can return information about the claimed manufacturer of the chip (some manufacturers provide a mechanism that allows users to change the character sequence returned by this instruction).

The behavior of some of the functions in Intel’s runtime library depends on the
character sequence returned by the CPUID instruction, producing better performance for the sequence “GenuineIntel”. The US Federal Trade Commission have filed a complaint alleging that this is anti-competitive (more details) and requested that this manufacturer dependency be removed.

I think that removing this manufacturer dependency will have little impact on sales. Any Intel compiler user who is not targeting Intel chips and who is has a real interest in performance can patch the runtime library, the Supercomputer crowd will want to talk to the kind of sophisticated processor/compiler engineers that Intel makes available and for everybody else it is about the perception of performance. In fact Intel ought to agree to a ‘manufacturer free’ runtime library pronto before too many developers have their delusions shattered.

CPUs also exhibit hardware faults

October 31st, 2009 Derek-Jones No comments

The cpu is the one element of a computing platform that people rarely treat as a source of error caused by physically malfunction, i.e., randomly flipping a bit in a register or instruction pipeline. I once worked on a compiler for the Mototola 88000 using a test platform that contained alpha silicon (i.e., not yet saleable components where some of the instructions were known not to work; the generated assembler code was piped through a sed script that mapped these instructions into an alternative instruction sequence that did work) and the cpus in a few of the hardware updates turned out to be temperature sensitive; some of the instructions changed their behavior when they got too hot. People who write compilers using alpha silicon learn to expect this sort of thing.

Quite a bit has been published on faults in other hardware components. Some of the best recent empirical hardware fault data and analysis I have seen is that published by Google engineers on hard disc and dram memory fault occurrences in their server farms. They might have a problem publishing such results for the cpus they use because these commodity items generally don’t have the ability to report any detailed fault data, they just die or one of the programs being executed crashes.

As device fabrication continues to shrink erroneous behavior caused by cosmic ray impact will become more and more common. Housing a computer farm at a high altitude might not be a good idea (at 7500 ft cosmic ray-induced neutrons that can lead to soft errors are 6.4 times more common than at sea level).

IBM’s Power4 chip (”Power4 System Design for High Reliability” by Bossen, Tendler and Reick) is one of the few that provides error checking of cache contents, while IBM’s System z9 is one of the very few that provide parity checking on the cpu registers (”Enhanced I/O subsystem recovery and availability on the IBM System z9″ by Oakes et al).

One solution to the problem of unreliable cpu behavior is for the compiler to insert consistency checks into the generated code. Two such checking methods are:

  • ‘Signature Analysis’ which performs consistency checks between signatures calculated at compile time and runtime. A signature is associated with every basic block with the current signature being derived from the execution history. This technique can detect spurious changes to the flow of control caused by a hardware glitch.
  • ‘Error Detection by Duplicated Instructions’ generates code which duplicates the behavior of some instruction sequence and compares the result calculated by both sequences, i.e., a source language construct is executed twice and an error raised if the results are different. The parallel instruction sequences use different sets of registers on the same cpu and ideally the instructions are scheduled to exploit instruction level parallelism

At the moment cosmic-ray induced hardware faults are probably very small change compared to faults in the code. Will code quality increase to the point where cosmic-ray faults become an issue or will devices get so small that they have to be lead lined to prevent background radiation corrupting them? Let the race begin.

Assuming compilers are clever enough (part 1)

May 12th, 2009 Derek-Jones 1 comment

Developers often assume the compiler they use will do all sorts of fancy stuff for them. Is this because they are lazy and happy to push responsibility for parts of the code they write on to the compiler, or do they actually believe that their compiler does all the clever stuff they assume?

An example of unmet assumptions about compiler performance is the use of const in C/C++, final in Java or readonly in other languages. These are often viewed as a checking mechanism, i.e., the developer wants the compiler to check that no attempt is made to, accidentally, change the value of some variable, perhaps via code added during maintenance.

The surprising thing about variables in source code is that approximately 50% of them don’t change once they have been assigned a value (A Theory of Type Qualifiers for C measurements and Automatic Inference of Stationary Fields for Java).

Developers don’t use const/final qualifiers nearly as often as they could. Most modern compilers can deduce if a locally defined variable is only assigned a value once and make use of this fact during optimization. It takes a lot more resources to deduce this information for non-local variables; developers want their compiler to be fast and so implementors don’t won’t them waiting around while whole program analysis is performed.

Why don’t developers make more use of const/final qualifiers? Is this usage, or lack of, an indicator that developers don’t have an accurate grasp of variable usage, or that they don’t see the benefit of using these qualifiers or perhaps they pass responsibility on to the compiler (program size seems to grow sufficiently fast that whole program optimization often consumes more memory than likely to be available; and when are motherboards going to break out of the 4G limit?)

Code generation via machine learning

April 2nd, 2009 Derek-Jones No comments

Commercial compiler implementors have to produce compilers that are capable of being used on a typical developer computer. A whole bunch of optimization techniques were known for years but could not be used because few computers had the available memory capacity (in the days when 2M was a lot of memory your author once attended a talk that presented some impressive results and was frustrated to learn that the typical memory footprint was 160M, who would ever imagine developers having so much memory to work within?) These days the available of gigabytes of storage has means that likely computer storage capacity is rarely a reason not to use some optimization technique, although the whole program optimization people are still out in the cold.

What is new these days is the general availability of multiple processors. The obvious use of multiple processors is to have make distribute the compilation load. The more interesting use is having the compiler apply different sets of optimizations techniques on different processors, picking the one that produces the highest quality code.

Optimizing code generation algorithms don’t appear to leave anything to chance and individually they generally don’t. However, selecting an order in which to apply individual optimization algorithms is something of a black art. In some cases code transformations made by one algorithm can interfere with the performance of another algorithm. In some cases the possibility of the interference is known and applies in one direction, choosing the appropriate relative ordering of the two algorithms solves the problem. In other cases the way in which two algorithms interfere with each other depends on the code being translated, now the ordering of the two algorithms becomes problematic. The obvious solution is to try both orderings and pick the one that produces the best result.

Several research groups have investigated the use of machine learning in compiler optimization. cTuning.org is a new project that aims to bring together groups interested in self-tuning adaptive computing systems based on statistical and machine learning techniques.
Commercial pressure is always forcing compiler implementors to produce faster code and use of machine learning techniques can produce some impressive results. Now that multi-processor systems are common it will not be long before compilers writers start to make use of the extra resources now available to them.

The safety critical people have problems trying to show the correctness of compiler output that has been generated by ‘fixed’ algorithms. It is not hard to envisage that in 10 years time all large production quality compilers will be using machine learning.

volatile handling sometimes overly volatile

March 2nd, 2009 Derek-Jones 1 comment

The contents of some storage locations, used by a program, might be modified outside of the control of that program, e.g., a real-time clock or the input port of a communications device. In some cases writing to particular storage locations has an external effect, e.g., a sequence of bits is sent down a communications channel. This kind of behavior commonly occurs in embedded systems

C and C++ support the existence of variables that have been mapped to such storage locations through the use of the volatile type qualifier.

volatile long flag;
volatile time_t timer;
 
struct {
                    int f1 : 2;
          volatile int f2 : 2;
                    int f3 : 3;
         } x;

When a variable is declared using volatile compilers must assume that its value can change in ways unknown to the compiler and that storing values into such a variable can have external effects. Consequently almost all optimizations involving such variables are off limits. Idioms such as timer = timer; are used to reset or refresh timers and are not dead code.

Volatile is a bit of an inconvenience for writers of code optimizers, requiring them to add checks to make sure the expression or statement they want to attempt to optimize does not contain a volatile qualified variable. In many environments the semantics of volatile are not applicable, which means that bugs in optimizers have a much smaller chance of being detected than faults in other language constructs.

There have been a number of research projects investigating the use of the const qualifier, but as far as I know only one that has investigated volatile. The ‘volatile’ project found that all of the compilers tested generated incorrect code for some of the tests. License agreements prevented the researchers giving details for some compilers. One interesting observation for gcc was that the number of volatile related faults increased with successive compiler releases; it looks like additional optimizations were being implemented and these were not checking for variables being volatile qualified.

One practical output from the project was a compiler stress tester targeting volatile qualified variables. The code generated by stress testers often causes compilers to crash and hang and the researchers reported the same experience with this tool.

There is one sentence in the C Standard whose overly broad wording is sometimes a source of uncertainty: What constitutes an access to an object that has volatile-qualified type is implementation-defined. This sentence applies in two cases: datatypes containing lots of bytes and bit-fields.

To save space/money/time/power some processors access storage a byte, or half-word, at a time. This means that, for instance, an access to a 32-bit storage location may occur as two separate 16-bit operations; from the volatile perspective does that constitute two accesses?

Most processors do not contain instructions capable of loading/storing a specified sequence of bits from a byte. This means that accesses to bit-fields involve one or more bytes being loaded and the appropriate bits extracted. In the definition of x above an access to field f1 is likely to result in field f2 (and f3) being accessed; from the volatile perspective does that constitute two accesses?

Unfortunately it is very difficult to obtain large quantities of source code for programs aimed at the embedded systems market. This means that it is not possible to obtain reliable information on common usage patterns of volatile variables. If anybody knows of any such code base please let me know.

www.wenn.com
FireStats icon Powered by FireStatswww.tinynibbles.com buy prescription propecia without

levitra sales uk

canadian viagra

order levitra online

order prescription propecia

canadian viagra and healthcare

lowest price for propecia

lowest propecia prices in canada

cialis and diarrhea

lowest cost levitra

gele viagra

name brand cialis

levitra low price

buy propecia now

canadian pharmacies cialis

lowest priced propecia

canada online pharmacy propecia

cialis delivered overnight

buying viagra in canada

get levitra online

levitra in india

canada propecia prescription

cheap canadian viagra

cialis professional 20 mg

indian cialis

how to get viagra

cialis professional 100 mg

buying propecia online

generic propecia 5mg

cost of propecia

buy cialis in usa

canadian online pharmacy cialis

buy propecia cheap

how much does cialis cost

get cialis

best way to use cialis

online cialis

cialis 100 mg generic

buy cialis cannada

cialis professional no prescription

order cheapest propecia online

best price propecia

cialis by mail

can i get viagra in mexico

buying levitra online

buying cialis next day delivery

mail order levitra

i need to buy propecia

cheap propecia uk

cialis vs levitra

online generic cialis 100 mg

lowest propecia 1 mg

cheap discount levitra

buy propecia online pharmacy

generic viagra made in usa

mexico levitra

levitra online us

cheap propecia online

generic propecia for sale

generic propecia sale

discount propecia online

overnight delivery cialis

canadian healthcare

low cost canadian viagra

online levitra

best viagra

buy levitra online viagra

brand viagra professional

discount drug propecia

cialis 50 mg

lowest propecia prices

discount propecia propecia

canada viagra

cheap levitra without prescription

lowest price propecia best

cheap fast levitra

cialis price

buy viagra germany canadian meds

generic levitra canada

ordering cialis gel

cialis profesional

cialis daily dosage pharmacy

buy cheap levitra

mexico pharmacy cialis

generic levitra overnight delivery

cialis 5 mg

cialis 20 mg

buy cialis online canada

canadian drugs propecia

levitra online overnight delivery

buy viagra online cheap us

levitra cheap fast

female viagra pills

cialis tablets foreign

how much to buy viagra in pounds

buy real cialis

brand viagra over the net

combine cialis and levitra

generic propecia alternative

levitra online sales

discount cialis india

generic levitra cheap

brand name cialis

generic levitra vardenafil

cialis pharmacy

generic cialis from india

cheap viagra from uk

cialis alternative

buy levitra online from canada

daily dosage cialis

cialis next day delivery

buy cheap generic levitra

order propecia

buy levitra overnight

cialis and canada custom

cialis discount

online pharmacy propecia viagra

cialis from mexico

buy propecia prescriptions online

cialis generic 100 mg

natural viagra

generic viagra 100 mg

cialis uk

buy generic propecia

cheap propecia online prescription

overnight delivery viagra

mail order propecia

levitra order prescription

ordering propecia online

generic viagra canada

buy cheapest propecia

cheap propecia no prescription

levitra viagra online

low cost propecia

cialis on women

cialis next day

mail online order propecia

canada meds viagra

cheap propecia 5mg

cialis no prescription

obtain viagra without prescription

generic levitra purchase

buy generic viagra india rx

best price cialis

internet pharmacy propecia

how much cialis

cialis quick shipment

buy levitra vardenafil

cialis headaches

canadian healthcare viagra

generic cialis next day shipping

cheap levitra tablets

buy cheap levitra online

best price generic propecia

buying generic cialis mexico rx

generic cialis sale

cheapest prices for viagra

cialis one a day

levitra prescription

cialis purchase

cialis 5 mg italia

next day delivery cialis

generic propecia fda approved

levitra 10mg

cialis fast delivery usa

cialis refractory

online cheap viagra

best price levitra

low price levitra

online propecia prescriptions

lowest price levitra

discount levitra online

getting cialis from canada

generic cialis soft tabs

lowest price on non generic levitra

canada viagra generic

levitra cost

buying cialis soft tabs 100 mg

how much is viagra

levitra buy online

cialis transdermal

best price for generic cialis

generic viagra made in india

levitra pill

buy cheap generic propecia

canada viagra pharmacies scam

genuine cialis pills

cheapest viagra online

cheap viagra online

levitra online prescription

cialis cheap us pharmacy

cialis overnight

how strong is 5 mg of cialis

buy propecia canada

5 mg daily cialis

buy fast propecia

buy can from i propecia who

cheapest viagra

buy cialis usa

once a day viagra

cialis to buy

cialis woman

canada cheap propecia

buying cialis

levitra canadian

cost levitra low

online ordering propecia

next day viagra

brand name cialis overnight

buy propecia without prescription

cialis fast delivery

buy 5 mg cialis

cheapest viagra usa

buy levitra us

cheapest overnight cialis

generic propecia online pharmacy

canadian pharmacy cialis

buy cialis online uk

buy now propecia

buy viagra

buy propecia on line

cheap levitra prescription

buy dosages levitra

cialis tablets

cost of viagra

discount levitra purchase

cheapest propecia sale uk

cialis price 100 mg

once daily cialis

indian generic levitra

canadian pharmacy viagra

order cheap propecia

cialis online

canadian viagra india

china viagra

levitra tabs

levitra now online

cheap viagra canada or india

canada levitra

cialis and ketoconazole

cialis en mexico

buy real viagra online

canadian pharmacy

buy propecia generic

cialis daily

low cost levitra

generic viagra canadian

buying online propecia

generic viagra india

online propecia uk

levitra viagra cialis

buying propecia

cheap cialis soft

order viagra or levitra

canadian propecia rx

get propecia online pharmacy

cheap levitra

cheap cialis from india

generic propecia effective

cialis cheap

buy online prescription propecia

cialis dosage mg

lowest price propecia

levitra in canada

buy levitra uk

buy viagra online

buy viagra without prescription

ganeric cialis

generic viagra online

canada generic propecia

levitra where to buy

generic propecia finasteride

buy propecia online

levitra for sale

buy propecia online from usa pharmacy

for sale levitra

buy cialis fedex shipping

buy branded viagra

cheapest propecia uk

buy viagra mexico

does generic cialis work

buy viagra china

buying generic propecia

cialis in mexico

buy cialis once daily

online viagra gel to buy

hydrochlorothiazide cialis

buy levitra online no prescription

cialis 100 mg

buy viagra on line

buy discount viagra

buy cialis without prescription

fda levitra

how to get cialis in canada

canadian viagra 50mg

get cialis online

discount propecia rx

buy cialis for daily use

order generic levitra

best price for propecia