WARNING : this page has been deprecated

some information may still be relevant.





How to compile samples

  • Install ocaml4multicore on your system (you must use a 64-bits Linux system).

Here is the installation documentation.
To quickly test ocaml4multicore with our Stop and Copy Garbage Collector and our samples, jump to the last item of this section.

  • The Garbage Collector code is in the ocaml4multicore/runtime/gcs folder.

It should be compiled if you have used our installation script.

  • To compile our samples, the garbage collector library (libgc.a) must be given to ocamlopt (you can’t compile to bytecode with ocamlc (yet) with ocaml4multicore)

We provide a Makefile which can compile ocaml sources with any compiled GC (compatible with ocaml4multicore) if it is in the right folder (ocaml4multicore/runtime/gcs/.

  • To specify the GC to the compilation command, you must put the name of your GC directory in the GC environment variable.

For instance, to use our Stop and Copy GC you can execute the following command:

export GC=sc_par
  • Now you can compile form the root of the ocaml4multicore folder with the following command:
make test

With this command every .ml file in the tests directory is compiled using ocaml4multicore. It was made to be used with single-file source code but you can easily adapt our Makefile to your needs.

  • If you want to simply compile our samples with our Stop and Copy Garbage Collector you can use this command:

GC=sc_par make test

How to add a Garbage Collector

  • Firstly, create a directory for the Garbage Collector in the ocaml4multicore/runtime/gcs directory.
  • Your Garbage Collector must use our gci.h interface.
/*** functions to implement ***/
 
/*modifies a pointed value*/
void gc_modify (value*, value) ;
/*alloc n BYTES uninitialized*/
value* gc_alloc_local_raw (asize_t) ;
/*alloc n VALUES with tag*/
value* gc_alloc_local (mlsize_t, int) ;
/*alloc n VALUES with tag*/
value* gc_alloc_shared (mlsize_t, int) ;
/*alloc n BYTES uninitialized, uncollectable*/
void* gc_alloc_stat (asize_t) ;
void* gc_resize_stat (void*, asize_t);
void gc_free_stat (void*) ;
/*call gc*/
void gc_invoke_local () ;
void gc_invoke_full () ;
/*called at program start*/
void gc_init ();
/*predicate to know wether a pointer has been allocated*/
int gc_allocated (void*);
/* called at thread start to initialize local data*/
void gc_init_local ();
/*called at thread stop*/
void gc_terminate_local ();
/* protect roots modifications */
void gc_begin_roots ();
void gc_end_roots ();
/* thread join implementation*/
void gc_wait_termination (struct caml_thread_descr *);
/*tweak to use mutexes*/
void gc_set_interrupted();
void gc_unset_interrupted();
 
/*** functions to use */
 
extern void caml_do_roots (void (*) (value, value *));
  • Just create a function for each prototype given in the interface.

You can see a description of these functions in the documentation.

 
manual.txt · Last modified: 2009/04/02 19:22 by philippe