Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re: small problem in bigarray module #2432

Closed
vicuna opened this issue Apr 28, 2000 · 2 comments
Closed

Re: small problem in bigarray module #2432

vicuna opened this issue Apr 28, 2000 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 28, 2000

Original bug ID: 94
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hi,

Thank you for your message to the Caml mailing list.

However your message seems to be a bug report; hence I send it to the
relevant mailing list

caml-bugs@inria.fr

Thank again for your interest in Caml.

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/

Hi,

I get the following behaviour in a custom toplevel with bigarray.cma
built in:

open Bigarray;;

let a = Array1.create float32 c_layout 4;;

val a : (float, Bigarray.float32_elt, Bigarray.c_layout)
Bigarray.Array1.t =

a.{0} <- 2.0;;

  • : unit = ()

a.{0};;

The external function `bigarray_get_1' is not available

It looks as though bigarray.ml and bigarray.mli refer to
"%bigarray_ref_1", but the C library function is called
"bigarray_get_1". The same thing happens for Array2 and Array3 as well.

Is this a bug, or have I done something wrong?

Also, why do some (but not all) references to external C functions begin
with a '%' sign? (apologies if this is in the documentation somewhere)

Regards,

--
Edwin Young

@vicuna
Copy link
Author

vicuna commented Apr 28, 2000

Comment author: administrator

I get the following behaviour in a custom toplevel with bigarray.cma
built in:

open Bigarray;;

let a = Array1.create float32 c_layout 4;;

val a : (float, Bigarray.float32_elt, Bigarray.c_layout)
Bigarray.Array1.t =

a.{0} <- 2.0;;

  • : unit = ()

a.{0};;

The external function `bigarray_get_1' is not available

It looks as though bigarray.ml and bigarray.mli refer to
"%bigarray_ref_1", but the C library function is called
"bigarray_get_1". The same thing happens for Array2 and Array3 as well.

Is this a bug, or have I done something wrong?

It is a bug. I enclose a small patch that fixes it. (After applying it, go to
otherlibs/bigarrays, make all allopt, make install installopt.)

Also, why do some (but not all) references to external C functions begin
with a '%' sign? (apologies if this is in the documentation somewhere)

It's not documented. Those '%' primitives correspond to primitive operations
that are treated specially by the compiler: some of them are expanded
into machine instructions, without calling any C function; others are
either expanded into machine instructions or into a call to a generic
C function, depending on the amount of type information available.

This is the case for "%bigarray_ref_1": it may be turned into a call
to "bigarray_get_1", or expanded in-line if enough type information is
known. However, this confused the "ocamlmktop" command, which,
basically, didn't see the implicit reference to "bigarray_get_1".

Thanks for the bug report.

Best regards,

  • Xavier Leroy

Index: csl/otherlibs/bigarray/bigarray.ml
diff -c csl/otherlibs/bigarray/bigarray.ml:1.5 csl/otherlibs/bigarray/bigarray.ml:1.6
*** csl/otherlibs/bigarray/bigarray.ml:1.5 Mon Feb 28 16:46:28 2000
--- csl/otherlibs/bigarray/bigarray.ml Fri Apr 28 13:32:07 2000


*** 10,16 ****
(* *)
(***********************************************************************)

! (* $Id: bigarray.ml,v 1.5 2000/02/28 15:46:28 xleroy Exp $ *)

(* Module [Bigarray]: large, multi-dimensional, numerical arrays *)

--- 10,16 ----
(* *)
(***********************************************************************)

! (* $Id: bigarray.ml,v 1.6 2000/04/28 11:32:07 xleroy Exp $ *)

(* Module [Bigarray]: large, multi-dimensional, numerical arrays *)


*** 187,190 ****
--- 187,200 ----
if Genarray.num_dims a = 2 then a else invalid_arg "Bigarray.array2_of_genarray"
let array3_of_genarray a =
if Genarray.num_dims a = 3 then a else invalid_arg "Bigarray.array3_of_genarray"
+

  • (* Force bigarray_get_{1,2,3,N} to be linked in, since we don't refer
  • to those primitives directly in this file *)
  • let _ =
  • let getN = Genarray.get in
  • let get1 = Array1.get in
  • let get2 = Array2.get in
  • let get3 = Array3.get in
  • ()

@vicuna
Copy link
Author

vicuna commented Apr 28, 2000

Comment author: administrator

Fixed on 2000-04-28 by Xavier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant