File: simplescale_array.ml

package info (click to toggle)
parmap 1.2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 356 kB
  • sloc: ml: 1,329; ansic: 132; makefile: 21
file content (41 lines) | stat: -rw-r--r-- 1,731 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(**************************************************************************)
(* Sample use of Parmap, a simple library to perform Map computations on  *)
(* a multi-core                                                           *)
(*                                                                        *)
(*  Author(s):  Roberto Di Cosmo                                          *)
(*                                                                        *)
(*  This program is free software: you can redistribute it and/or modify  *)
(*  it under the terms of the GNU General Public License as               *)
(*  published by the Free Software Foundation, either version 2 of the    *)
(*  License, or (at your option) any later version.                       *)
(**************************************************************************)

open Parmap
open Utils

let compute p = 
  let r=ref 1 in 
  for i = 1 to 80000 do 
    r:= !r+(p*p)-(p*(p-1))
  done;
  !r
;;

let fcompute p = 
  let r=ref 1. in 
  for i = 1 to 80000 do 
    r:= !r+.(p*.p)-.(p*.(p-.1.))
  done;
  !r
;;

array_scale_test fcompute (Array.init 20000 (fun i -> float_of_int i)) 2 1 10;;
array_scale_test ~chunksize:100 ~inorder:false fcompute (Array.init 20000 (fun i -> float_of_int i)) 2 1 10;;
array_scale_test ~chunksize:100 ~keeporder:true fcompute (Array.init 20000 (fun i -> float_of_int i)) 2 1 10;;

array_float_scale_test fcompute (Array.init 20000 (fun i -> float_of_int i)) 2 1 10;;

scale_test ~chunksize:100 ~inorder:false compute (A (Array.init 20000 (fun i -> i))) 2 1 10;;
scale_test ~chunksize:100 ~keeporder:true compute (A (Array.init 20000 (fun i -> i))) 2 1 10;;

scale_test compute (A (Array.init 20000 (fun i -> i))) 2 1 10;;