* NaCl
is relatively new to ocaml and was hoping not to get down into the guts like this
mal`` has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
<thelema>
NaCl: you can have mutually recursive modules within one file, but separate compilation + mutual recursion = error
<thelema>
try to change your design so the two files don't reference each other.
<NaCl>
hmmmm
<NaCl>
I'm going to have to think on this
mal`` has joined #ocaml
<NaCl>
I know how I could do it, but it wouldn't make too much sense
<NaCl>
or...
<thelema>
what are you trying to do?
<NaCl>
Well, the first problem I had I think I could fix by moving some type declarations to a separate file.
<thelema>
yes, usually you should put the common type declarations in its own file
<NaCl>
Actually, that may solve the problem.
* NaCl
is translating C into ocam
<NaCl>
l
avsm has joined #ocaml
<NaCl>
thelema: yeah, I think the solution is spreading some stuff out. Let's see if that works
mlh has quit [Ping timeout: 250 seconds]
mlh has joined #ocaml
philtor has joined #ocaml
oriba has joined #ocaml
oriba has left #ocaml []
<NaCl>
Just when I'm about to complain about a difficulty I'm having, I find a solution for it
<thelema>
the task of trying to explain your problem to complain about it helps a lot in terms of realizing what the solution to the problem is.
<NaCl>
indeed
<NaCl>
the problem is: I am making a Ray Tracer. Scene specifications contain Lights. Lights need to call the scene "intersect with the primitive list" routine
<NaCl>
both are in two files, and call each other.
<thelema>
put the types for both in one file, and have lights depend on scene.
<NaCl>
and looking at my C++ implementation of this thing, that list is supposed to be a tree, and not even called from this file.
<thelema>
or realize that the "lights calling the scene" code can be in the scene file
<NaCl>
yeah, it can
<NaCl>
I haven't gotten to shadows yet, but they're going to pop up eventually
<thelema>
you're thinking OO, where code that works on lights *must* be in the lights class
ygrek has joined #ocaml
<NaCl>
yeah
<NaCl>
I'm trying to learn functional programming. Unfortunately, I may not be able to use it much.
thieusoai has joined #ocaml
alexgordon has joined #ocaml
alexgordon has left #ocaml []
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
mfp has quit [Read error: Connection reset by peer]
mfp has joined #ocaml
lpereira has joined #ocaml
ftrvxmtrx has quit [Quit: This computer has gone to sleep]
olauzon has joined #ocaml
strlen has quit [Quit: switching to erc]
strlen has joined #ocaml
Associat0r has joined #ocaml
Associat0r has quit [Changing host]
Associat0r has joined #ocaml
ulfdoz has joined #ocaml
sepp2k has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
lpereira has quit [Quit: Leaving.]
ftrvxmtrx has joined #ocaml
hto_ has joined #ocaml
lamawithonel has joined #ocaml
hto has quit [Ping timeout: 260 seconds]
munga has quit [Read error: Operation timed out]
joelr has joined #ocaml
<joelr>
folks, how do i get ocamlopt to show me the assembly code?
<thelema>
-S
<joelr>
thelema: this is after all optimizations are applied, right? by ocamlopt
<thelema>
yes, it's the final assembly
<joelr>
thelema: thanks
<joelr>
thelema: trying to optimize math here
<thelema>
there's no intermediate assembly generated, all optimizations are done to a different representation
<adrien>
"after all optimizations are applied": yeah, after all 3 of them :P
<joelr>
hehe
<joelr>
thelema: is there unsafe array access?
<thelema>
Array.unsafe_get arr idx
<thelema>
you can turn all array access unsafe with -unsafe
<joelr>
aha!
<thelema>
-unsafe No bounds checking on array and string access
<joelr>
by looking at the output from ocamlopt -dcmm
<joelr>
haven't looked at the assembly yet
<thelema>
acc := +. d1 +. d2
<thelema>
does this even compile?
<joelr>
err
<joelr>
it does :D
<thelema>
I thought the patches to add unary + were just added to the devel branch
<joelr>
it drops that first plus, though
<joelr>
the truly interesting part is that the second version i have does not allocate on every loop iteration
<joelr>
thelema: check it out
<joelr>
same pastie, just edited
<thelema>
try comparing your function with [let rec js_div1 v1 v2 acc i = if i >= Array.length v1 then ((L4-L8)) in js_div1 v1 v2 (acc +. d1 +. d2) (i+1) else acc]
<thelema>
err, i < Array.length v1
<thelema>
yes, there's some wierd rules on float boxing, maybe if you change L11 to (!acc + 0.) it'll avoid allocation in the first implementation
<joelr>
thelema: loops are faster than recursive functions, e.g. there's no boxing
DimitryKakadu has joined #ocaml
<joelr>
thelema: is there an unsafe length function?
<flux>
maybe it could unsafely work on any data type.. ;)
yezariaely has joined #ocaml
hto_ has quit [Ping timeout: 260 seconds]
yezariaely has left #ocaml []
<thelema>
with an array size of 500K instead of 500, the differences between 1a, 2 and 3 disappear
mcclurmc_home has joined #ocaml
Snark has quit [Quit: Ex-Chat]
jderque has quit [Quit: leaving]
ankit9 is now known as ankit9|zzz
<joelr>
thelema: looking
<joelr>
thelema: we use arrays of 150 elements
<joelr>
thelema: i didn't know about the benchmark package, thanks a lot!
Associat0r has quit [Quit: Associat0r]
<joelr>
thelema: this gives me some fine ideas for benchmarking, actually
<joelr>
thelema: because in the code that uses this the arrays v2 are stored in a record in a hash table so memory access should be all over the place
<joelr>
i would like to try to stick the floats into a memory-mapped float file instead, and get hold of them via Bigarray.Array1.map_file + unsafe_get
avsm has quit [Quit: Leaving.]
Associat0r has joined #ocaml
hto has joined #ocaml
vivanov has quit [Read error: Connection reset by peer]
elehack has joined #ocaml
lamawithonel_ has joined #ocaml
lamawithonel has quit [Ping timeout: 264 seconds]
avsm has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
ulfdoz_ is now known as ulfdoz
joelr has quit [Quit: joelr]
Associat0r has quit [Quit: Associat0r]
ymasory has quit [Quit: Leaving]
_andre has quit [Quit: leaving]
edwin has quit [Remote host closed the connection]
joelr_ has joined #ocaml
joelr_ has quit [Client Quit]
mcclurmc_home has left #ocaml []
DimitryKakadu has quit [Remote host closed the connection]
smerz has quit [Quit: Ex-Chat]
Tianon has quit [Read error: Operation timed out]
ymasory has joined #ocaml
alpounet has quit [Read error: Operation timed out]
alpounet has joined #ocaml
avsm has quit [Quit: Leaving.]
boscop_ is now known as boscop
waern has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
elehack has quit [Quit: Farewell, programs.]
jonafan has quit [Ping timeout: 252 seconds]
lamawithonel_ has quit [Ping timeout: 246 seconds]