Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Noalias trivia question Message-ID: <7832@brl-smoke.ARPA> Date: 4 May 88 18:29:29 GMT References: <56@lakart.UUCP> <1164@maccs.UUCP> <270@sdrc.UUCP> <871@sun.mcs.clarkson.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 29 In article <871@sun.mcs.clarkson.edu> mrd@sun.mcs.clarkson.edu (Michael R. DeCorte) writes: >I NEED something that will allow me to write a C >compiler that can vectorize and concurentize code. What should I do? The first thing you need to realize is that C has always been capable of aliasing objects via pointers, and it has been (tacitly) assumed that all references to aliased objects will access the same thing, not distinct cached copies of the object. Thus, C has never permitted optimization along the lines that people expect for Fortran. To obtain such optimization it is incumbent on the programmer to take some special steps to flag those cases that can be optimized, unless his system provides really good global flow analysis across multiple translation units (source files). "noalias" is not the only possible mechanism for this; a less ambitious one would be a vendor-specific hook such as a compiler option, a magic /*comment*/, or even a __keyword that flags places where aliasing can safely be ignored. The obvious such place is at function interfaces, since it is extremely poor style for a function to be required to access the same object both directly as an extern and indirectly via a pointer parameter. It has been suggested that [] formal parameters have this special meaning, although they can't by default in a Standard-conforming implementation (you would have to enable the special treatment by a compiler option). There is some disagreement whether #pragma can be used to change such semantics. Both the Redactor (draft Standard editor) and I think not, but I've heard other X3J11 members voice contrary opinions. You should discuss this with your compiler vendor. First ask for good global data access analysis (although it's unlikely that you'll get it), then ask for a compiler flag for special treatment of [] parameters, then ask for a __keyword.