Trying to get a NN code going

John van Groningen johnvg@cs.kun.nl
Tue, 2 Mar 1999 16:54:29 +0100


Richard A. O'Keefe wrote:
>        The Clean compiler does not automatically inline functions,
>
>Ah.  That's a bit disappointing.  These days, C compilers _do_, and
>Ada compilers even offer cross-module inlining.
>
>Naturally, the functions that need to be inlined as tight loops
>(and which the C compiler _does_ inline) are recursive functions
>in Clean, so I _can't_ rewrite them as macros.

After "The Clean compiler does not automatically inline functions," I wrote:

>>Macros can not be recursive, but a recursive function can still be written as
>>a macro by using a recursive local function in the macro, see for example
>>foldl and foldr.

For example:

        loop f r i n a = if (i<n) (loop f (f r a.[i]) (i+1) n a) r

can be written as a macro:

        loop f r i n a :== loop r i
                where
                        loop r i = if (i<n) (loop (f r a.[i]) (i+1)) r

>        The compiler does not unroll loops and does not have an
>        instruction scheduler.
>        
>I didn't expect it to unroll list-based loops, although there are
>said to be (experimental) functional compilers that can.  I _do_
>expect any compiler for today's CPUs (Sparc, Alpha, Mips, PowerPC,
>Pentium family) to put a fair bit of effort into instruction
>scheduling.  It's hard, of course, which is why Mercury uses gcc
>to do it.

The performance improvements I get by scheduling instructions for PowerPC and Pentium family processors for integer code are very low. Therefore implementing an instruction scheduler has a low priority.
Scheduling does however improve the performance of some programs that use floating point calculations.

>This is great news, but why isn't in the man page?
>clean/man/man1/clm.1
>starts with
>    .TH CLM 1 "May 14 1998" "Version 1.3"
>and contains no mention of any -ci option at all.
>What's more, when I actually try to _use_ the 1.3 compiler, it says
>    unknown option: -ci

It is not in the manual page, because Clean 1.3 for Unix/Linux do not support it. Clean 1.3.1 and 1.3.2 do.

>        >I hoped that the Macintosh version might be a bit better, but when
>        >I try to _compile_ the program on a PowerMac 7600/120 running MacOS 8.1,
>        >an Errors window pops up, containing
>        >
>        >    Fatal Error in comsupport:TH_Alloc "Insufficient Memory"
>        
>        The CleanCompiler needs to be resized with the Finder or ResEdit
>        (SIZE resource).  You can quit the CleanCompiler by pressing any
>        key, or by quiting the CleanIDE.
>        
>Yes, but what should I resize it *TO*?  Is there any rule of thumb that
>relates source complexity to memory requirements?

The worst I have seen is 6 Mb for a module for which the compiler generated 400k of machine code.

>
>        You can get a stack trace of the top of the stack on the
>        PowerMac or Windows by enabling the time profiler
>
>GREAT!  Is this going to be available in UNIX versions soon?

No.

John van Groningen