Problem: ciomalloc error when many LUTs are allocated. This problem has to do with reduced I/O address space in the "newer" SPARCstations. We've prepared an example of how to get around this in "ftp://im.lcs.mit.edu/cam8/memory/more-luts.exp". You'll also need the other file in this directory, "link-mem.c". You need to make an object file from this using "gcc -c link-mem.c". Briefly the problem is that, starting with its sum4m machines, Sun has restricted the amount of memory that can be made visible to an I/O device such as our CAM-8 SBus interface. Thus you are unable to allocate more than about 25 LUTs in the I/O address space (3 MBytes). You actually have much more memory available in the SPARCstation, but it can't be allocated in the I/O address space. We don't yet have an automatic solution to this problem. In the example we provide, the solution we give is to allocate as many buffers as you like in the user address space, and copy them into a common buffer in the I/O space as you need them. A better solution would be to remap buffers, rather than copy them, but we haven't made provision for that as yet. --------------------------- more-luts.exp -------------------------- \ Allocating LUTs in non-I/O space memory \* Because newer Sun machines have a very limited amount of I/O address space (only about 4Mbytes usable by CAM), if you have many LUT's you can't allocate them all in this address space, which is where "create-lut" would normally put them. Our CAM software does not at present deal with this problem automatically. What you need to do is put some or all of these extra buffers in non-I/O address space, and copy into CAM LUT buffers as you need them. In the example below, we define only a single LUT buffer using "create-lut". Note that the step that downloads the buffer is followed by the word "stop", to make sure that this step is completely executed before you change "lut-buffer" again. The word "stop" just schedules an empty step list. Scheduling any other step list that doesn't use "lut-buffer" would have the same effect: execution of the Forth will not continue until the new list has started, which means that the previous list has finished, and so its safe to change "lut-buffer". *\ new-experiment 512 by 512 space \ 1) link in some extra memory-management routines. Make sure \ "link-mem.o" is in the current directory. This is constructed from \ "link-mem.c" using "gcc -c link-mem.c": first-clink on "" ./link-mem.o clink : malloc (s #bytes -- address ) _c_malloc drop ret ; \ 2) allocate non-cam buffers each 128 K bytes long, to hold all of your \ tables. "malloc" leaves a pointer to the buffer on the stack. We \ define constants to remember these pointers. 128 K malloc constant buf0 128 K malloc constant buf1 128 K malloc constant buf2 \ 3) allocate a lut buffer create-lut lut-buffer \ 4) use this one buffer in turn with each of your rules and ?rule>table \ to compile all the tables on disk that you'll need. After each rule \ is compiled, copy lut-buffer into a non-cam buffer. The argument \ order for "cmove" is (s source.address destination.address length -- ) \ and "lut-buffer buffer" leaves the address of "lut-buffer" on the \ stack: : rule0 cell not -> cell ; : rule1 cell 1+ -> cell ; : rule2 cell 1- -> cell ; ?rule>table rule0 lut-buffer lut-buffer buffer buf0 128 K cmove ?rule>table rule1 lut-buffer lut-buffer buffer buf1 128 K cmove ?rule>table rule2 lut-buffer lut-buffer buffer buf2 128 K cmove \ 5) Define step lists that only use one buffer ("lut-buffer"). Before \ each step is scheduled, copy the necessary lut into "lut-buffer". \ Note that each step is followed by "stop", to ensure that you don't \ change "lut-buffer" until after the previous step is finished: define-step cstep lut-data lut-buffer switch-luts site-src lut lut-src site kick run end-step buf0 lut-buffer buffer 128 K cmove cstep stop buf1 lut-buffer buffer 128 K cmove cstep stop buf2 lut-buffer buffer 128 K cmove cstep stop \ 6) You should free the memory you've allocated before reloading the \ experiment, since "new-experiment" won't know about this memory. If \ you don't do this, exiting "step" will free this memory. : mfree (s address -- ) _kfree drop ; : free-my-bufs buf0 mfree buf1 mfree buf2 mfree ; ------------------------------- link-mem.c ------------------------- #include #include #include void kfree(char *ptr) { free(ptr); } char *c_malloc(unsigned size) { return(malloc(size)); } /* This is here to force these functions to linked from a library */ int dummy() { int alignment, size, addr, len, prot, flags, fd, off; memalign(alignment,size); mmap(addr,len,prot,flags,fd,off); munmap(addr,len); }