Skip to content

Commit

Permalink
added Magic.threemult to use 3+3 complex-multiply variant when possible
Browse files Browse the repository at this point in the history
[empty commit message]
  • Loading branch information
stevengj committed Apr 18, 2008
1 parent b21cf57 commit 5d2811a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 13 additions & 2 deletions genfft/complex.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,20 @@ let nan x = CE (NaN x, makeNum Number.zero)

let half = inverse_int 2

let times3x3 (CE (a, b)) (CE (c, d)) =
CE (makePlus [makeTimes (c, makePlus [a; makeUminus (b)]);
makeTimes (b, makePlus [c; makeUminus (d)])],
makePlus [makeTimes (a, makePlus [c; d]);
makeUminus(makeTimes (c, makePlus [a; makeUminus (b)]))])

let times (CE (a, b)) (CE (c, d)) =
CE (makePlus [makeTimes (a, c); makeUminus (makeTimes (b, d))],
makePlus [makeTimes (a, d); makeTimes (b, c)])
if not !Magic.threemult then
CE (makePlus [makeTimes (a, c); makeUminus (makeTimes (b, d))],
makePlus [makeTimes (a, d); makeTimes (b, c)])
else if is_constant c && is_constant d then
times3x3 (CE (a, b)) (CE (c, d))
else (* hope a and b are constant expressions *)
times3x3 (CE (c, d)) (CE (a, b))

let ctimes (CE (a, _)) (CE (c, _)) =
CE (CTimes (a, c), makeNum Number.zero)
Expand Down
4 changes: 4 additions & 0 deletions genfft/magic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let circular_min = ref 64
let rader_min = ref 13
let rader_list = ref [5]
let alternate_convolution = ref 17
let threemult = ref false
let inline_single = ref true
let inline_loads = ref false
let inline_loads_constants = ref false
Expand Down Expand Up @@ -78,6 +79,9 @@ let speclist = [
"-rader-min", set_int rader_min,
"<n> : Use Rader's algorithm for prime sizes >= <n>";

"-threemult", set_bool threemult,
" Use 3-multiply complex multiplications";

"-karatsuba-min", set_int karatsuba_min, undocumented;
"-karatsuba-variant", set_int karatsuba_variant, undocumented;
"-circular-min", set_int circular_min, undocumented;
Expand Down

0 comments on commit 5d2811a

Please sign in to comment.