Home > Uncategorized, data analysis > Designing a processor for increased source portability costs

Designing a processor for increased source portability costs

February 9th, 2010 Derek-Jones

How might a vendor make it difficult for developers to port open source applications to their proprietary cpu? Keeping the instruction set secret is one technique, another is to design a cpu that breaks often relied upon assumptions that developers have about the characteristics of the architecture on which their code executes.

Of course breaking architectural assumptions does not prevent open source being ported to a platform, but could significantly slow down the migration; giving more time for customers to become locked into the software shipped with the product.

Which assumptions should be broken to have the maximum impact on porting open source? The major open source applications (e.g., Firefox, MySQL, etc) run on 32/64-bit architectures that have an unsigned address space, whose integer representation uses two’s complement arithmetic and arithmetic operations on these integer values wrap on over/underflow.

32/64-bit. There is plenty of experience showing that migrating code from 16-bit to 32-bit environments can involve a lot of effort (e.g., migrating Windows 286/386 code to the Intel 486) and plenty of companies are finding the migration from 32 to 64-bits costly.

Designing a 128-bit processor might not be cost effective, but what about a 40-bit processor, like a number of high end DSP chips? I suspect that there are many power-of-2 assumptions lurking in a lot of code. A 40-bit integer type could prove very expensive for ports of code written with a 32/64-bit mindset (dare I suggest a 20-bit short; DSP vendors have preferred 16-bits because it uses less storage?).

Unsigned address space (i.e., lowest address is zero). Some code assumes that addresses with the top bit set are at the top end of memory and not just below the middle (e.g., some garbage collectors). Processors having a signed address space (i.e., zero is in the middle of storage) are sufficiently rare (e.g., the Inmos Transputer) that source is unlikely to support a HAS_SIGNED_ADDRESS build option.

How much code might need to be rewritten? I have no idea. While the code is likely to be very important there might not be a lot of it.

Two’s complement. Developers are constantly told not to write code that relies on the internal representation of data types. However, they might be forgiven for thinking that nobody uses anything other than two’s complement to represent integer types these days (I suspect Univac does not have that much new code ported to it’s range of one’s complement machines).

How much code will break when ported to a one’s complement processor? The representation of negative numbers in one’s complement and two’s complement is different and the representation of positive numbers the same. In common usage positive values are significantly more common than negative values and many variables (having a signed type) never get to hold a negative value.

While I have no practical experience, or know of anybody who has, I suspect the use of one’s complement might not be that big a problem. If you have experience please comment.

Arithmetic that wraps (i.e., positive values overflow negative and negative values underflow positive). While expressions explicitly written to wrap might be rare, how many calculations contain intermediate values that have wrapped but deliver a correct final result because they are ‘unwrapped’ by a subsequent operation?

Arithmetic operation that saturate are needed in applications such as graphics where, for instance, increasing the brightness should not suddenly cause the darkest setting to occur. Some graphics processors include support for arithmetic operations that saturate.

The impact of saturation arithmetic on portability is difficult to judge. A lot of code contains variables having signed char and short types, but when they appear as the operand in a binary operation these are promoted to int in C/C++/etc which probably has sufficient range not to overflow (most values created during program execution are small). Again I am lacking in practical experience and comments are welcome.

Floating-point. Many programs do not make use of floating-point arithmetic and those that do rarely manipulate such values at the bit level. Using a non-IEEE 754 floating-point representation will probably have little impact on the portability of applications of interest to most users.

Update. Thanks to Cate for pointing out that I had forgotten to discuss why using non-8-bit chars does is not a worthwhile design decision.

Both POSIX and the C/C++ Standards require that the char type be represented in at least 8 bits. Computers supporting less than 8-bits were still being used in the early 80s (e.g., the much beloved ICL 1900 supported 6-bit characters). The C Standard also requires that char be the smallest unit of addressable storage, which means that it must be possible for a pointer to point at an object having a char type.

Designing a processor where the smallest unit of storage is greater than 8-bits but not a power-of-2 is likely to substantially increase all sorts of costs and complicate things enormously (e.g., interfaces to main memory which are designed to work with power of two interfaces). The purpose of this design is to increase other people’s cost, not the proprietary vendor’s cost.

What about that pointer requirement? Perhaps the smallest unit of storage that a pointer could address might be 16 or 40 bits? Such processors exist and compiler writers have used both solutions to the problems they present. One solution is for a pointer to contain the address of the storage location + offset of the byte within that storage (Cray used this approach on a processor whose pointers could only point at 64-bit chunks of storage, with the compiler generating the code to extract the appropriate byte), the other is to declare that the char type occupies 40-bits (several DSP compilers have taken this approach).

Having the compiler declare that char is not 8-bits wide would cause all sorts of grief, so lets not go there. What about the Cray compiler approach?

Some of the address bits on 64-bit processors are not used yet (because few customers need that amount of storage) so compiler writers could get around host-processor pointers not supporting the granularity needed to point at 8-bit objects by storing the extra information in ‘unused’ pointer bits (the compiler generating the appropriate insertion and extraction code). The end result is that the compiler can hide pointer addressability issues :-).

  1. February 9th, 2010 at 08:31 | #1
  2. cate
    February 9th, 2010 at 09:35 | #2

    You forgot some usual assumptions:
    - char is 8 bits (from POSIX)
    - strange endianness (it seems that a lot of program uses custom function to transform data)
    - pointer are longer than long (IIRC since C99)

    The first two items are important to read binary files (e.g. images) or from network. Programs use custom function but now that all devices must share data such assumptions could slow down porting applications.

  3. February 9th, 2010 at 12:01 | #3

    @Tony Finch
    The diagram on that page clearly shows zero at the bottom and FFF… at the top. In a signed address space zero sits in the middle of memory. I did not see any obvious errors in the article saying that the address space was signed.

  4. February 9th, 2010 at 12:43 | #4

    @cate Thanks for pointing out that I need to discuss 8-bit chars; now done!

    The Intel x86 and many RISC chips have opposite byte endianness which ensures that this issue is addressed by a lot of Open Source code. What about word endianness (i.e., swapping 16-bit quantities) like that used by the DEC (now HP) VAX? This is an interesting possibility that I had overlooked.

    Having pointers occupy more bits than a long (the IBM RS/400 has 16 byte pointers!) introduces all sorts of extra costs for the processor vendor, so I don’t think that this is a cost effective option.

  1. No trackbacks yet.
Comments are closed.
FireStats icon Powered by FireStatscialis testimonial

cialis at real low prices

cialis and canada custom

cheap canadian viagra

cheap viagra from uk

buying viagra in canada

discount drug propecia

levitra cheap

cialis philippines

buying viagra in the us

is pfizer viagra available in india

cialis buy

buy propecia cheap

cialis refractory

buy mg propecia

lowest price levitra

cialis pfizer

brand viagra without prescription buy

buy levitra american pharmacy

levitra sex pill

canadian viagra

chip cialis

buy cialis online without prescription

cialis angioplasty

non pescription cialis

cheap propecia no prescription

cost of daily cialis

generic cialis next day delivery

buy cheap online propecia

cialis soft tablets

buying viagra with no prescription

levitra in mexico

info levitra

levitra buy online

canadian viagra and healthcare

cialis transdermal

cialis testimonial

generic cialis india discount

one day delivery cialis

5 mg cialis

discount levitra online

cialis tablets

cialis no rx

buy cialis in usa

buy cialis online without prescription

canadian levitra

brand viagra

generic propecia online pharmacy

cost levitra

mexico propecia

buy generic cialis

cheap levitra without prescription

cialis canadian cost

cialis c 50

canadian pharmacy viagra legal

get viagra fast

herbal propecia

cialis dose

online generic cialis 100 mg

buying cialis without a prescription

dose cialis

buy 5 mg cialis

levitra canada prescription

cialis canadian cost

buy cialis fedex shipping

cialis 5 mg

cialis generic

5 mg daily cialis

canadian healthcare cialis

cialis 5 mg buy

levitra cheap fast

discount levitra online us

canadian healthcare pharmacy

buy propecia uk

order viagra or levitra

bruising on cialis

cheap cialis soft

index

cheap propecia online

cheap levitra tablets

buy viagra online canada

best levitra prices

buy propecia online without prescription

cialis professional no prescription

cialis endurance

cialis daily canada

cialis

buy vardenafil levitra

levitra vs viagra

canadian generic viagra online

online generic cialis 100 mg

mail order levitra

buy cialis online uk

brand name cialis overnight

cialis purchase

generic viagra online

best propecia prices

bruising on cialis

cialis for women

buy cheap propecia online

canada online pharmacy levitra

levitra lowest price

cialis 100 mg

online propecia uk

canada viagra generic

best price for generic cialis

generic levitra online

cialis dosage

best viagra

buy cialis 5 mg

5mg propecia

buy pfizer viagra online

brand cialis

generic cialis sale

buy now viagra

overnight canadian viagra

canadian viagra india

for sale levitra

levitra online sales

buy viagra germany canadian meds

lowest priced propecia

cialis 20 mg

cheapest propecia pharmacy online

how much to buy viagra in pounds

buy cheap levitra online

online propecia prescription

cheap discount levitra

buy cialis in canada

levitra canadian pharmacy

cheap online levitra

cialis for woman

cialis levitra sales

buy cialis canada

50 mg cialis dose

cialis delivered overnight

buy viagra on line

best price generic propecia

cheap propecia canada

cialis generic

buy generic propecia

get propecia cheap

growth hair propecia

buy xenical propecia

no prescription viagra

cialis alternatives

brand viagra over the net

buy xenical propecia

canadian levitra

cialis 100 mg generic

buy levitra us

cialis daily dosing cost

online viagra gel to buy

buying cialis soft tabs 100 mg

canadian pharmacy

buy viagra without prescription

buy fast propecia

cialis alternative

5 mg original brand cialis

buy levitra online no prescription

name brand cialis

levitra

cialis daily availability

get propecia online pharmacy

non prescription viagra

levitra mail order

cialis online without prescription

generic viagra online

generic cialis next day shipping

low price cialis

buy cheapest cialis

cialis fast delivery

buy propecia online prescription

cialis medication

cialis fast

levitra cheap canadian pharmacy

buy viagra online canada

discount cialis

best viagra

discount levitra rx

buy real viagra online without prescription

bestellen levitra

cialis from mexico

buy viagra online cheap us

generic cialis

bio viagra herbal

gel viagra

cheapest prices for viagra

buy cheap propecia online

buy generic cialis

levitra without prescriptions

cialis kanada

buying viagra

canadian propecia rx

cheapest propecia in uk

internet pharmacy propecia

cialis cheap

levitra prescription

buy viagra mexico

cialis canada online pharmacy

how much is viagra

drug hair loss propecia

how does viagra work

buy cialis

buy prescription propecia without

generic levitra cheap

cialis dosagem

effect of cialis on women

cialis delivered overnight

cialis endurance

china viagra

cialis fast delivery usa

indian cialis canada

discount levitra online viagra

buy propecia where

online propecia cheap

cheap viagra canada or india

buy cheapest cialis

cheap propecia 5mg

generic cialis in india

canadian pharmacy discount code viagra

buy cialis 5 mg

generic propecia sale

cialis professional

buy levitra now

cheap levitra tablets

healthcare of canada pharmacy

cialis generic 100 mg

cialis cost canada

buy canada in propecia

cialis india pharmacy

canada viagra generic

cheap price propecia

levitra where to buy

levitra next day delivery

no prescription propecia

canadian viagra india

cialis brand name

cheap cialis from india

buying levitra online

canadian healthcare pharmacy

how to get cialis

daily cialis

cheap cialis

bying viagra online cheap us

buy cialis in usa

cialis okay for women

cialis and ketoconazole

levitra online us

buy canada levitra

cialis for less 20 mg