Re: [Caml-list] thousands of CPU cores

2008-09-22 Thread Alan Schmitt

On 21 sept. 08, at 23:41, Jon Harrop wrote:

The good news is that the parallel GC is coming along nicely and  
this will be

a solved problem before long... :-)


I'd love to hear more about this. Could you develop?

Alan


PGP.sig
Description: This is a digitally signed message part
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] What's the purpose of the static library?

2008-09-22 Thread Stéphane Glondu

bill yan a écrit :

I noticed there are some static libraries(.a) installed with ocaml, for
example, /usr/lib/ocaml/bigarray.a. What's the purpose of those static
libraries? Thanks a lot.


They contain (natively) compiled OCaml code. An OCaml library compiled 
in native mode (usually) consists of a .a and a .cmxa file, the former 
containing OCaml-specific information.


They are not to be confused with lib*.a files, which contain compiled C 
stubs, and are needed for generating native-code executables, and 
bytecode ones in -custom mode.



Cheers,

--
Stéphane

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] Portable PNG exporter

2008-09-22 Thread Janne Hellsten
As my tiny PNG exporter got more attention than I anticipated, let me
clarify a couple of things:

- My OCaml code is based on a C function written by Tero Karras.  I
  merely rewrote his masterpiece in OCaml.  The C version is available
  here:

  
http://code.google.com/p/aihiot/source/browse/trunk/gfx/save_bitmap/c/save_bitmap.c

- The trick is to save out uncompressed PNGs.  This gets rid of the
  zlib dependency.  Although the files get bigger, uncompressed .png
  is still very useful.

On Sun, Sep 21, 2008 at 2:03 AM, Richard Jones <[EMAIL PROTECTED]> wrote:
> On Sat, Sep 20, 2008 at 08:37:22PM +0300, Janne Hellsten wrote:
>> While working on a graphics related problem, I needed to save the
>> contents of a Graphics framebuffer to a .png file.  Quick googling for
>> "ocaml png" didn't bring up any results for libraries that would be
>> easy to install via GODI.  I am aware of CamlImages but unfortunately
>> I have never been successful at installing it due its heavy dependence
>> on external libraries.  I also often work on Windows and installing
>> external OCaml libraries on Windows is usually a major PITA (if
>> possible at all).
>
> Hmmm .. GODI?

If you meant why didn't I install CamlImages via GODI, well, not
because of lack of trying.  I quickly got into a conf packages hell
trying to figure out which devel packages I'm missing.  It wasn't the
first time I was trying to install it and I quickly decided against
spending time on it.  This was on Linux.

If you meant GODI on Windows, well..

I like GODI and am a long-time user of it.  However, installation on
Windows is not very easy and (at least last time I tried) requires
Cygwin.  I prefer to work natively on Windows and I really dislike
emulating Unix with Cygwin (slow, broken, you name it).

Now, if I was the only one hacking on my code on Cygwin+GODI, things
would be pretty OK and I could live with the occasional "I can't get
GODI to install on my broken Cygwin installation/this package doesn't
compile on Cygwin/...".  The problem is that all my collegues use
Windows and aren't familiar with OCaml, GODI or Cygwin.  If something
goes wrong during GODI or a particular package installation, they
won't be able to solve the issue without my help.  This has pretty
effectively ruined my attempts to use OCaml for internal tools.

My OCaml environment nowadays consists of the following:

- OCaml MSVC version (Win32 installer, no Cygwin required)

- OMake (Win32 installer, no Cygwin required during installation or use)

- No external libraries (with the exception of ExtLib which is just a
  bunch of .ml files and thus easy to build)

This obviously limits what I can do with OCaml.  In fact, I have often
needed to resort to using Python (the horror!) for some of my scripts.
Everyone's already got Python installed and so my scripts work without
any installation.

It's too easy to dismiss Windows installation problems by suggesting
everyone to just adopt Linux.  Unfortunately that's not an option for
me.  I see value in being able to port from Unix to Windows and vice
versa.

> Your code is surprisingly elegant .. I didn't think it was possible to
> write out a PNG file in such few lines.  I wonder if it would be more
> concise using bitstring.

Doing 32-bit (<> 31-bit) integer on OCaml was a bit of a pain and it
shows.  If Bitstring helps you write more concise 32-bit ALU ops, then
I'd imagine the code would be more concise.  Manipulating bit fields
was not a big issue with .png though.

Updating Adler and CRC in functional style was probably not a good
idea, an imperative version would be easier to read and maintain.  Not
to mention feeling a bit naughty when doing I/O inside a fold_left. :)

> For reference, I've found the easiest way to export PNGs (in any
> language, not just OCaml) is to use netpbm.  Simply fork pnmtopng
> using Unix.open_process_out and write a PPM file.

I usually write out .tga which is also very easy to write and most
programs open it.  I wanted to have .png to be able to view them in
generated HTML reports.

Saving a .tga is quite easy, copy&pasting from
http://code.google.com/p/aihiot/source/browse/trunk/gfx/save_bitmap/ocaml/tga.ml:

(** Save a .tga file to chnl. *)
let write_tga_chnl chnl pixels w h =
  let header =
[0; 0; 2; 0; 0; 0; 0; 0; 0; 0; 0; 0;
 w land 255; w lsr 8;
 h land 255; h lsr 8; 32; 8] in
  List.iter (fun e -> output_byte chnl e) header;
  for y = 0 to h-1 do
for x = 0 to w-1 do
  let c = pixels.(x+(h-1-y)*w) in (* h-1-y = Flip image *)
  output_byte chnl (c land 255);
  output_byte chnl ((c lsr 8) land 255);
  output_byte chnl ((c lsr 16) land 255);
  output_byte chnl 255;
done
  done

Janne

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria

Re: [Caml-list] Portable PNG exporter

2008-09-22 Thread Daniel Bünzli


Le 22 sept. 08 à 16:59, Janne Hellsten a écrit :


- The trick is to save out uncompressed PNGs.  This gets rid of the
 zlib dependency.  Although the files get bigger, uncompressed .png
 is still very useful.


and you can compress them later with pngcrush [1].

Daniel

[1] http://en.wikipedia.org/wiki/Pngcrush

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] thousands of CPU cores

2008-09-22 Thread Jon Harrop
On Monday 22 September 2008 08:51:03 Alan Schmitt wrote:
> On 21 sept. 08, at 23:41, Jon Harrop wrote:
> > The good news is that the parallel GC is coming along nicely and
> > this will be a solved problem before long... :-)
>
> I'd love to hear more about this. Could you develop?

Sure thing. I wrote to the guys doing this work a couple of times and they 
were very friendly. Apparently they are currently ironing out the last of the 
bugs before going public.

I don't think I am the only person struggling to contain my excitement. :-)

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] Portable PNG exporter

2008-09-22 Thread Florent Monnier
> For reference, I've found the easiest way to export PNGs (in any
> language, not just OCaml) is to use netpbm.

Probably with any language, but perhaps not any OS ?

>  Simply fork pnmtopng
> using Unix.open_process_out and write a PPM file.  A PPM file has such
> a simple format that you can write it directly from just about any
> language, even a shell script.
>
>   P3   255
>   followed by xx3 RGB triplets (in decimal, separated
>   by writespace)

You can reduce the amount of exchanged datas using binary ppm instead of ascii 
ppm. In such case the format is:

  P6\n \n255\n
  followed by xx3 RGB triplets of octect (in binary)

Here is the OCaml code I use, as well for jpeg:

let output_ppm ~oc ~img:(_, r_channel, g_channel, b_channel) =
  let width = Bigarray.Array2.dim1 r_channel
  and height = Bigarray.Array2.dim2 r_channel in
  Printf.fprintf oc "P6\n%d %d\n255\n" width height;
  for y = 0 to pred height do
for x = 0 to pred width do
  (* output_byte doesn't raise any exception about the range *)
  output_char oc (char_of_int r_channel.{x,y});
  output_char oc (char_of_int g_channel.{x,y});
  output_char oc (char_of_int b_channel.{x,y});
done;
  done;
  output_char oc '\n';
  flush oc
;;

(* you can use different conversion commands (convert is from ImageMagick) *)
let print_jpeg ~img ?(quality=96) () =
  let cmd = Printf.sprintf "cjpeg -quality %d" quality in
  (*
  let cmd = Printf.sprintf "ppmtojpeg -quality %d" quality in
  let cmd = Printf.sprintf "convert ppm:- -quality %d jpg:-" quality in
  *)
  let ic, oc = Unix.open_process cmd in
  output_ppm ~img ~oc;
  try
while true do
  let c = input_char ic in
  print_char c
done
  with End_of_file -> ()
;;

(* output any of the hundred formats ImageMagick knows *)
let print_file ~img ~format =
  let cmd = Printf.sprintf "convert ppm:- %s:-" format in
  let ic, oc = Unix.open_process cmd in
  output_ppm ~img ~oc;
  try
while true do
  let c = input_char ic in
  print_char c
done
  with End_of_file -> ()
;;

let new_img ~width ~height =
  let all_channels =
let kind = Bigarray.int8_unsigned
and layout = Bigarray.c_layout
in
Bigarray.Array3.create kind layout 3 width height
  in
  let r_channel = Bigarray.Array3.slice_left_2 all_channels 0
  and g_channel = Bigarray.Array3.slice_left_2 all_channels 1
  and b_channel = Bigarray.Array3.slice_left_2 all_channels 2
  in
  (all_channels,
   r_channel,
   g_channel,
   b_channel)
;;
_

Anyway I'm very pleased to see this png exporter, while it's allways usefull 
to remove an external dependency !
Thanks for this piece of code !

-- 
Florent

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] thousands of CPU cores

2008-09-22 Thread David Teller
On Mon, 2008-09-22 at 20:03 +0100, Jon Harrop wrote:
> Sure thing. I wrote to the guys doing this work a couple of times and they 
> were very friendly. Apparently they are currently ironing out the last of the 
> bugs before going public.
> 
> I don't think I am the only person struggling to contain my excitement. :-)

  *
*_o/
|/
   / 


'nuff said
-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings 
liquidations. 

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] Issue to compile a program with camlp4 in OCaml 3.10.0

2008-09-22 Thread David MENTRE
Hello,

I'm trying to compile an OCaml program I haven't written. I'm compiling
it on an Ubuntu 8.04, OCaml 3.10.0.

The compilation fails with following error:
"""
ocamlopt -pp "camlp4o pa_op.cmo" -I src  -c src/common.ml
File "src/common.ml", line 5, characters 101-102:
Parse error: "in" expected after [binding] (in [expr])
Preprocessor error
"""

Here is the beginning of the relevant file:
"""
(** Common utility functions. *)

(* space *)

let heap_size () : float = float_of_int (Gc.stat ()).Gc.heap_words *. 
float_of_int (Sys.word_size / 8)  (* in bytes *)

"""

This expression seems correct to me. Is this issue related to one of the
fixes on camlp4 that where made in 3.10.1?

Any idea how to work around this issue (without recompiling latest ocaml
and all the needed libraries)?

Sincerly yours,
david
-- 
GPG/PGP key: A3AD7A2A David MENTRE <[EMAIL PROTECTED]>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] Dum: dumper module with cycle detection

2008-09-22 Thread Martin Jambon

Hi list,

Wink.com is releasing a module called Dum for dumping data.
It derives from Dumper by Richard W Jones (now Std.dump in Extlib) and
from Size by Jean-Christophe Filliatre.

   http://oss.wink.com/dum/

The main improvement over the original Dumper is that shared values 
and therefore cycles are detected and labelled:


# let rec loopy = 1 :: 2 :: loopy in Dum.p loopy;;
- : string = "#0: (1 (2 #0))"

Dum was originally developed to print the maximum out of uncaught 
exceptions, since the standard Printexc.to_string does not go arbitrarily 
deep and this was occasionally a source of frustration.


Now data such as closure fields and object fields are dumped like regular 
data without causing particular problems or worries.


The output is pretty-printed and its size limit is configurable.


Enjoy!


Martin, for Wink.

--
http://wink.com/

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] thousands of CPU cores

2008-09-22 Thread kirillkh
What about the standard library being single-threaded? How hard will it be
to adjust it for multiple threads, will OCaml maintainers even agree to such
adjustments and how will this affect performance?

On Mon, Sep 22, 2008 at 10:03 PM, Jon Harrop <
[EMAIL PROTECTED]> wrote:

> On Monday 22 September 2008 08:51:03 Alan Schmitt wrote:
> > On 21 sept. 08, at 23:41, Jon Harrop wrote:
> > > The good news is that the parallel GC is coming along nicely and
> > > this will be a solved problem before long... :-)
> >
> > I'd love to hear more about this. Could you develop?
>
> Sure thing. I wrote to the guys doing this work a couple of times and they
> were very friendly. Apparently they are currently ironing out the last of
> the
> bugs before going public.
>
> I don't think I am the only person struggling to contain my excitement. :-)
>
> --
> Dr Jon Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com/?e
>
> ___
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] Issue to compile a program with camlp4 in OCaml 3.10.0

2008-09-22 Thread Gabriel Kerneis
On Mon, Sep 22, 2008 at 10:41:52PM +0200, David MENTRE wrote:
> ocamlopt -pp "camlp4o pa_op.cmo" -I src  -c src/common.ml
> File "src/common.ml", line 5, characters 101-102:
> Parse error: "in" expected after [binding] (in [expr])
> Preprocessor error
> 
> let heap_size () : float = [...]

Does the following solve the problem?

  val heap_size () : float = [...]

If it does, it has to do with revised syntax and you should change the flags
of camlp4 (but it believe camlp4o loads the classic syntax, so it might be a
bug as well).

Regards,
-- 
Gabriel Kerneis

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs