Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!osu-eddie!osupyr!hrubin From: hrubin@osupyr.UUCP Newsgroups: comp.lang.c Subject: Re: Portable C vs Efficient C or "Cost of Portability" Message-ID: <170@osupyr.UUCP> Date: Sat, 4-Apr-87 11:04:17 EST Article-I.D.: osupyr.170 Posted: Sat Apr 4 11:04:17 1987 Date-Received: Wed, 8-Apr-87 03:01:47 EST References: <213@pyuxe.UUCP> <1024@epimass.UUCP> Organization: Department of Statistics Lines: 29 Keywords: portability, performance Summary: I rarely find portability for efficient code I frequently find that reasonably good code can be portable, but rarely do I find efficient code portable. In fact, rarely do I find C code (or any other HLL) to be efficient. Assuming that the compiler allows you to put all the variables (but not, of course, the arrays)in registers, the following fragment of code is better on VAXen t = *(m++) ^ *(h++); *(k++) = t; *(z++) ^= t; than t = m[x] ^ h[x]; k[x] = t; z[x] ^= t; x++; while on the pyramid the reverse is true. This is because of the computer architecture. When operations not supported by C are needed, clearly the problem is worse. -- Herman Rubin Until mid May: Department of Statistics, Cockins Hall, 1958 Neil Avenue Ohio State University, Columbus OH43210 hrubin@osupyr or cbosgd!osu-eddie!osupyr!hrubin or ts0474@ohstvma.bitnet "Permanent": Department of Statistics, Purdue University, West Lafayette IN47907 hrubin@l.cc.purdue.edu or ihnp4!pur-ee!stat-l!hrubin or hrubin@purccvm.bitnet