* Re: [Caml-list] Re: complex bigarrays
@ 2001-11-08 23:13 David Gurr
0 siblings, 0 replies; 8+ messages in thread
From: David Gurr @ 2001-11-08 23:13 UTC (permalink / raw)
To: caml-list, ohl; +Cc: xavier.leroy
> OTOH, there are many numerical libraries (e.g. LAPACK) that
> explicitely declare two REAL arrays and use the entries as real and
> imaginary parts. However, this is a library choice and sidesteps
> Fortran's COMPLEX type altogether.
There are also libraries that do Re[C(1)] Re[C(2)] Im[C(1)] Im[C(2)]
etc in order to make use of Altivec packed arith.
-D
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Caml-list] Re: OCaml speed
@ 2001-11-06 9:05 Rolf Wester
2001-11-08 9:28 ` [Caml-list] Re: complex bigarrays Xavier Leroy
0 siblings, 1 reply; 8+ messages in thread
From: Rolf Wester @ 2001-11-06 9:05 UTC (permalink / raw)
To: caml-list
Christophe Raffalli wrote:
> Rolf Wester a écrit :
> >
> > Hi,
> >
> > I used the array access example from
> > http://www.bagley.org/~doug/shootout/ to compare c/c++ speed against
> > ocaml. The sources I used are attached below. Unfortunately I could
> > not confirm the given cpu times which are 0.11 sec for gcc and 0.13
> > for ocamlopt. My results on a Compaq Alpha True64 are 0.05 for cxx,
> > 0.1 for g++ and 0.29 for ocamlopt. Does anybody have an idea what
> > could be the reason for this inconsistency? Did I do anything wrong?
> >
>
> Your code mainly does integer operations and array accesses.
>
> The main difference between C and Ocaml are the reserved bit in integer
> used by ocaml for the GC. Then the generated assembly code are really
> different and it is possible that this diffrence cost nothing (almost)
> on a pentium and a lot on a Alpha True64.
>
> May be Xavier Leroy could look at the assembly code to tell if I am
> right ?
>
> You could also try with float arrays which should make less difference
> for your code ?
>
I tried it with floats. The differences are quite similar. With -unsafe I
get a speedup of almost 100%.
I mostly do numerical computations with heavy use of arrays. OCamls
array performance is sufficient for some of my applications but there are
still quite a lot of problems that need better performance so I'm stuck
with C/C++ either as OCaml extension or without OCaml. I'm thinking about
a numerical extension written in C comparable to the Python Numpy package.
At the moment I try to interface with the FFTW library. The biggest
problem is that there is no OCaml build in type complex and that the
Bigarray doesn't have complex too (sometime ago I read that someone was
thinking about adding complex numbers to the Bigarray module, I would
appreciate this very much).
Rolf Wester
-------------------------------------
Rolf Wester
rolf.wester@ilt.fraunhofer.de
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Re: complex bigarrays
2001-11-06 9:05 [Caml-list] Re: OCaml speed Rolf Wester
@ 2001-11-08 9:28 ` Xavier Leroy
2001-11-08 14:59 ` Rolf Wester
2001-11-08 15:35 ` Thorsten Ohl
0 siblings, 2 replies; 8+ messages in thread
From: Xavier Leroy @ 2001-11-08 9:28 UTC (permalink / raw)
To: Rolf Wester; +Cc: caml-list
> The biggest problem is that there is no OCaml build in type complex
> and that the Bigarray doesn't have complex too (sometime ago I read
> that someone was thinking about adding complex numbers to the
> Bigarray module, I would appreciate this very much).
Adding complex arrays to the Bigarray module is on my to-do list.
One issue is how these arrays should be represented to allow
no-copying exchange between C and Fortran. My understanding is that
in C, arrays of complex are generally represented as arrays of pairs
of floats (or doubles), while in Fortran some codes use the C
representation (one array of pairs) while others use a pair of arrays.
The array-of-pairs representation fits well the Bigarray interface,
but the pair-of-arrays approach does not.
Could someone with numerical experience in Fortran provide more
information on this?
- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Re: complex bigarrays
2001-11-08 9:28 ` [Caml-list] Re: complex bigarrays Xavier Leroy
@ 2001-11-08 14:59 ` Rolf Wester
2001-11-08 15:35 ` Thorsten Ohl
1 sibling, 0 replies; 8+ messages in thread
From: Rolf Wester @ 2001-11-08 14:59 UTC (permalink / raw)
To: caml-list
Hi Xavier;
can you please tell me when this complex Bigarrays are likely to be
available?
Rolf Wester
-------------------------------------
Rolf Wester
rolf.wester@ilt.fraunhofer.de
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Re: complex bigarrays
2001-11-08 9:28 ` [Caml-list] Re: complex bigarrays Xavier Leroy
2001-11-08 14:59 ` Rolf Wester
@ 2001-11-08 15:35 ` Thorsten Ohl
[not found] ` <81DA66D2-D46E-11D5-82F9-003065BDAA76@mac.com>
1 sibling, 1 reply; 8+ messages in thread
From: Thorsten Ohl @ 2001-11-08 15:35 UTC (permalink / raw)
To: caml-list; +Cc: Xavier Leroy
Xavier Leroy writes:
> while in Fortran some codes use the C representation (one array of
> pairs) while others use a pair of arrays.
>From section 4.3.1.3 of the Fortran standard:
The values a complex type are ordered pairs of real values. The
first real value is called the real second real value is called
the imaginary part.
and from section 14.6.3.1 of the Fortran standard:
(1) A nonpointer scalar object of type default integer, default
real, or default logic occupies a single numeric storage unit;
(2) A nonpointer scalar object of type double precision real or
default complex occupies two contiguous numeric storage units;
If you declare
COMPLEX C(2)
it is layed out as
Re[C(1)] Im[C(1)] Re[C(2)] Im[C(2)]
Fortran compilers have no freedom here, because they must support
EQUIVALENCE and COMMON aliasing.
OTOH, there are many numerical libraries (e.g. LAPACK) that
explicitely declare two REAL arrays and use the entries as real and
imaginary parts. However, this is a library choice and sidesteps
Fortran's COMPLEX type altogether.
--
Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de
http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2001-11-09 8:38 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-08 23:13 [Caml-list] Re: complex bigarrays David Gurr
-- strict thread matches above, loose matches on Subject: below --
2001-11-06 9:05 [Caml-list] Re: OCaml speed Rolf Wester
2001-11-08 9:28 ` [Caml-list] Re: complex bigarrays Xavier Leroy
2001-11-08 14:59 ` Rolf Wester
2001-11-08 15:35 ` Thorsten Ohl
[not found] ` <81DA66D2-D46E-11D5-82F9-003065BDAA76@mac.com>
2001-11-08 17:56 ` Thorsten Ohl
2001-11-08 18:12 ` Joerg Czeranski
2001-11-08 18:20 ` Ken Rose
2001-11-08 18:35 ` David McClain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox