Archive

Posts Tagged ‘one’s complement’

Designing a processor for increased source portability costs

February 9th, 2010 Derek-Jones 4 comments

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 :-).

FireStats icon Powered by FireStatscheap propecia uk

cheap propecia online

bruising on cialis

buy fast propecia

map of france with cialis

generic propecia india

cheap viagra online

herbal propecia

buying viagra without prescription

cialis 50 mg dose

online viagra gel to buy

cialis daily cost

best prices for propecia

cialis by mail

cialis canadian cost

cheap prescription propecia

canadian online pharmacy cialis

cialis no rx

cheapest propecia sale uk

buy viagra pills

levitra price

buy cialis online without prescription

online ordering propecia

buy cialis next day delivery

generic form of propecia

generic propecia alternative

buy now online propecia

herbal viagra

levitra paypal

buy propecia online pharmacy

cheapest viagra online

levitra prices

chip cialis

generic viagra made in india

canadian healthcare viagra sales

cheap online levitra

cialis daily dosage pharmacy

buy levitra vardenafil

cialis arterial fibrillation

cheap viagra generic

brand cialis for sale

cheapest propecia pharmacy online

canada online pharmacy levitra

cialis fast

levitra mg

best price levitra

cialis quick shipment

cialis blood thinner

no prescription viagra

cialis dose

canada levitra

canadian healthcare viagra sales

cialis for less 20 mg

online propecia uk

generic cialis professional

buying generic cialis mexico rx

cialis for less 20 mg

buy generic levitra

cheapest overnight cialis

cheapest propecia in uk

cialis on women

get propecia prescription

best levitra price

buying real viagra without prescription

cialis dosage

best price generic propecia

buy dosages levitra

cialis on line pricing in canada

cheap propecia online prescription

generic viagra 100 mg

cialis 5 mg

chip cialis

buy pfizer viagra online

buy levitra american pharmacy

lowest propecia prices in canada

buy cialis

cialis tablets

is pfizer viagra available in india

cialis cheap

buy generic levitra

buying cialis online

buy viagra online canada

low price cialis

generic cialis next day shipping

beta blockers and viagra

discount levitra online us

best price for propecia online

cialis dosagem

cialis daily

daily cialis cost

lowest price propecia costs us

buy levitra online viagra

brand name cialis

cheap viagra canada or india

order usa viagra online

cialis samples in canada

cialis professional no prescription

generic viagra propecia

cialis for women

buy viagra online

buy cheap generic propecia

levitra buying

cialis low price

cost levitra

discount drug propecia

best price for generic cialis

order generic levitra

generic propecia effective

buy generic cialis

levitra 10mg

cheap levitra online

buy real cialis

low price levitra

cialis at real low prices

lowest propecia price

discount us propecia

buy propecia in canada

canada generic propecia

buy propecia cheap

best way to take cialis

best way to take cialis

cialis fast

cialis 50 mg

cheap cialis fast delivery time

5 mg cialis canada

canadian levitra

levitra tablet

cialis usa

no prescription propecia

buy propecia cheap

cialis by women

lowest price propecia

buy cheap propecia

buy 5 mg cialis

indian cialis canada

buy generic viagra india rx

cialis cost

get levitra online

map of france with cialis

generic viagra online

indian cialis

cialis strenght mg

online order viagra overnight delivery

generic propecia cheap

discount canadian cialis

online cheap viagra

cialis 5 mg buy

buy propecia online prescription

buy cialis in usa

5mg propecia

brand name cialis

cost of viagra in germany

generic cialis canadian

cheap order prescription propecia

cialis delivered overnight

female viagra pills

best online generic levitra

buying real viagra without prescription

buy prescription propecia

canadian propecia cheap

cheapest overnight cialis

cialis for woman

order propecia online

discount levitra purchase

cialis alternative

generic propecia for sale

cheap propecia no prescription

buy generic levitra online

buying viagra in the us

cialis and canada custom

cheapest propecia sale uk

cialis philippines

cialis canada illegal buy

levitra or viagra

canadian viagra and healthcare

cheapest online propecia

how does viagra work

ordering viagra overnight delivery

canadian drugs propecia

cheap propecia order online

cheapest price propecia cheap

cialis tablets vs viagra

bestellen levitra

buy real cialis

cheap levitra uk

levitra where to buy

brand name cialis overnight

buy cialis usa

cheap order prescription propecia

cialis usa

buy pfizer viagra in canada

buy viagra in canada

buy propecia without prescription

bio viagra herbal

levitra buy online

cialis headaches

buy cialis online uk

bying viagra online cheap us

canada online pharmacy levitra

generic viagra india

cialis 50 mg dose

buy levitra with no prescription

canada viagra

buy cialis fedex shipping

bestellen levitra

levitra cost

about cialis

cialis cost

best price cialis

canada viagra

buy cialis online without prescription

buy viagra germany canadian meds

buy viagra online cheap us

buy cheapest cialis

buying viagra without prescription

buy cheap generic levitra

buy viagra pills

best way to take cialis

generic levitra canada

cheap viagra generic

cialis dosage mg

cialis express delivery

online prescription propecia

combine cialis and levitra

cialis canada

cheap levitra prescription

buy propecia no prescription

buying viagra in the us

cialis alternatives

canadian healthcare pharmacy

best price for generic cialis

china viagra

cialis generic

cialis next day

cialis 5 mg italia

cialis brand name

order propecia prescriptions

cialis arterial fibrillation

canadian pharmacy discount code viagra

hydrochlorothiazide cialis

cialisis in canada

cialis no prescription

cialis canada online pharmacy

online pharmacy propecia

cheap levitra uk

buy mg propecia

discount brand name cialis

cialis price

cialis dosagem

fast propecia