Archive

Posts Tagged ‘compiler’

Assessing my predictions for 2009

January 24th, 2010 Derek-Jones 1 comment

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 1 comment

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 cialis next day delivery

online propecia uk

discount generic propecia

lowest price propecia

buying levitra online

buy cialis online canada

cialis discount

cialis strenght mg

online cheap viagra

buy levitra us

canada generic propecia

cialis cheap

cheap fast levitra

for sale levitra

cialis by mail

generic cialis soft tabs

cialis and ketoconazole

buy propecia online pharmacy

order prescription propecia

buy viagra without prescription

how much cialis

low price levitra

buying propecia online

buy propecia without prescription

ganeric cialis

online pharmacy propecia renova

canadian pharmacy discount code viagra

generic propecia for sale

buy propecia where

buy cheap levitra online

generic viagra made in usa

cialis price

next day viagra

best price cialis

cialis en mexico

herbal propecia

how much is viagra

buy levitra online viagra

buying propecia

buy branded viagra

generic levitra overnight delivery

levitra low price

buying online propecia

name brand cialis

cheap prescription propecia

discount propecia online

cialis 20 mg

indian viagra

cialis from mexico

mail order propecia

cialis overnight delivery

levitra online overnight delivery

cialis daily dosage pharmacy

cheapest viagra

canadian viagra and healthcare

cialis headaches

cialis for woman

cialis quick shipment

buying cialis

info levitra

buying cialis soft tabs 100 mg

how much does cialis cost

cialis professional 20 mg

canadian pharmacy cialis

buy propecia prescriptions online

indian cialis

buy cialis in usa

buy propecia online from usa pharmacy

discount cialis india

bestellen levitra online

cheap levitra without prescription

get cialis online

cheap order prescription propecia

once daily cialis

cialis tablets foreign

discount us propecia

cialis soft pills

best price levitra

canadian pharmacy viagra

gele viagra

best way to use cialis

cialis fast delivery usa

canadian healthcare

cost of viagra

cheap propecia online

buy propecia online

canadian drugs propecia

cost of daily cialis

canadian pharmacy

cialis and diarrhea

buy can from i propecia who

buy viagra online cheap us

levitra online sales

generic viagra india

buy cheap levitra

indian generic levitra

cialis vs levitra

natural viagra

canada meds viagra

canadian viagra 50mg

5 mg original brand cialis

generic propecia effective

discount propecia rx

lowest propecia prices in canada

levitra mg

cialis in mexico

cialis profesional

cheap discount levitra

levitra canadian

generic propecia finasteride

low cost canadian viagra

cheapest propecia sale uk

canada online pharmacy propecia

buy cialis canada

cheap levitra tablets

cheap propecia 5mg

how to get cialis in canada

canadian propecia rx

levitra online prescription

buy viagra on line

get propecia online pharmacy

levitra buy online

discount levitra rx

generic levitra vardenafil

online viagra gel to buy

buy generic cialis

cialis price in canada

generic propecia online pharmacy

best price propecia

levitra cheap fast

get levitra online

50 mg cialis

levitra online

generic viagra 100 mg

generic propecia sale

cialis alternative

buy cheap generic propecia

buy real cialis

buy propecia canada

cialis from canada

cheapest viagra online

fda levitra

buy cialis fedex shipping

levitra from canadian pharmacy

lowest price levitra

hydrochlorothiazide cialis

buy viagra china

levitra online us

cialis no prescription

cialis 50 mg

online generic cialis 100 mg

buy cialis for daily use

cialis transdermal

cialis fast delivery

canadian healthcare viagra

online pharmacy propecia viagra

cheap viagra canada or india

buy fast propecia

generic levitra online

canada online pharmacy levitra

buy prescription propecia without

brand name cialis overnight

levitra mail order

how to buy cialis in canada

levitra where to buy

buy propecia on line

cialis to buy

buying viagra in canada

canada propecia prescription

buy viagra germany canadian meds

best viagra

cialis 100 mg generic

canadian viagra

cheapest viagra usa

canadian viagra india

china viagra

best price for propecia

best price for generic cialis

levitra in india

brand cialis for sale

cheapest prices for viagra

cialis overnight

cialis one a day

levitra viagra cialis

generic cialis next day shipping

generic levitra canada

buy levitra online from canada

generic viagra online

buy now propecia

buying generic propecia

indian cialis generic

buy levitra online no prescription

best price generic propecia

overnight delivery viagra

generic cialis from india

drug generic propecia

online cialis

levitra pill

generic propecia fda approved

levitra tabs

cheap canadian viagra

online levitra

cialis pharmacy

mail order levitra

once a day viagra

ordering propecia online

cheap propecia no prescription

discount propecia propecia

cialis dosage mg

canada cheap propecia

buying cialis next day delivery

buy generic viagra india rx

mexico levitra

canada viagra

does generic cialis work

levitra next day delivery

lowest price propecia best

levitra viagra online

how to get viagra

cheap levitra

levitra for sale

cialis 5 mg buy

cialis purchase

buy levitra uk

5 mg daily cialis

lowest propecia 1 mg

buy propecia cheap

buying generic cialis mexico rx

female viagra pills

generic propecia 5mg

internet pharmacy propecia

levitra discount

levitra prescription

levitra 10mg

cheap propecia uk

buy levitra vardenafil

cialis prescription

cialis delivered overnight

cheapest propecia uk

low cost propecia

low cost levitra

buy cialis usa

cialis 5 mg italia

how strong is 5 mg of cialis

mail online order propecia

levitra cost

buy cialis without prescription

cialis next day

cialis price 100 mg

cialis cheap us pharmacy

cialis buy overnight

online ordering propecia

getting cialis from canada

canada viagra pharmacies scam

buy discount viagra

genuine cialis pills

order generic levitra

buy dosages levitra

levitra order prescription

levitra online no prescription

generic cialis sale

buy cialis 5 mg

cost of propecia

cialis professional no prescription

cialis daily

generic propecia alternative

obtain viagra without prescription

lowest cost levitra

cialis refractory

cialis and canada custom

overnight delivery cialis

cialis on women

brand viagra professional

cheap viagra from uk

cheap viagra online

order cheapest propecia online

get cialis

cheap levitra prescription

mexico pharmacy cialis

order cheap levitra

cheap levitra uk

cialis professional 100 mg

generic viagra made in india

cheap propecia online prescription

cialis 100 mg

next day delivery cialis

order propecia

cialis online

order viagra or levitra

canadian healthcare pharmacy

canadian pharmacies cialis

cheapest propecia prescription

buy cheap generic levitra

buy online prescription propecia

cialis discounts

cialis generic 100 mg

order cheap propecia

cheapest overnight cialis

buy viagra

buy canada levitra