Changeset 3923 for trunk/ProjectFortress/demos
- Timestamp:
- 07/06/09 14:54:51 (5 months ago)
- Files:
-
- 1 modified
-
trunk/ProjectFortress/demos/DemoGenerator22D.fss (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/demos/DemoGenerator22D.fss
r3917 r3923 1 1 (******************************************************************************* 2 Generator-of-Generators Library is copyrighted free software by Kento Emoto 3 <emoto[at]ipl.t.u-tokyo.ac.jp> developed under the collaborative 4 research on Fortress Programming Language between Sun Microsystems, 5 Inc. and the University of Tokyo. 2 Generator-of-Generators Library is copyrighted free software by Kento Emoto 3 <emoto[at]ipl.t.u-tokyo.ac.jp> developed under the collaborative 4 research on Fortress Programming Language between Sun Microsystems, 5 Inc. and the University of Tokyo. 6 6 7 You can redistribute it and/or modify it under the following 7 You can redistribute it and/or modify it under the following 8 8 BSD-style license or the Sun Contributor Agreement that Kento Emoto signed. 9 9 10 Copyright (c)2009 by Kento Emoto10 Copyright 2009 by Kento Emoto 11 11 All rights reserved. 12 12 13 Redistribution and use in source and binary forms, with or without 14 modification, are permitted provided that the following conditions 13 Redistribution and use in source and binary forms, with or without 14 modification, are permitted provided that the following conditions 15 15 are met: 16 16 17 * Redistributions of source code must retain the above copyright 17 * Redistributions of source code must retain the above copyright 18 18 notice, this list of conditions and the following disclaimer. 19 * Redistributions in binary form must reproduce the above copyright 20 notice, this list of conditions and the following disclaimer 21 in the documentation and/or other materials provided with the 19 * Redistributions in binary form must reproduce the above copyright 20 notice, this list of conditions and the following disclaimer 21 in the documentation and/or other materials provided with the 22 22 distribution. 23 * Neither the name of Kento Emoto nor the names of its 24 contributors may be used to endorse or promote products derived 23 * Neither the name of Kento Emoto nor the names of its 24 contributors may be used to endorse or promote products derived 25 25 from this software without specific prior written permission. 26 26 27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 29 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 31 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 32 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 33 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 34 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 35 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 36 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 29 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 31 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 32 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 33 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 34 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 35 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 36 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 37 37 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 38 … … 59 59 (* the optimization works well *) 60 60 rundemo(i) = do 61 xs = array[\Number\]( (sizes[i],sizes[i]) ).fill(fn (ij):ZZ32 => |\random(10)-5/|) 61 xs = array[\Number\]( (sizes[i],sizes[i]) ).fill(fn (ij):ZZ32 => |\random(10)-5/|) 62 62 demo() = do 63 st = nanoTime() 63 st = nanoTime() 64 64 ans=BIG MAX[\Number\] <|[\Number\] SUM[\Number\] r | r <- rects xs |> 65 65 et = nanoTime() 66 66 t = et - st 67 67 ss = t / 1000000000.0 68 68 69 69 n = sizes[i] 70 70 println("mrs of " n "x" n " in " t " ns ( " ss " s) (the answer is " ans")") … … 78 78 79 79 println ("computing the maximum rectangle sum (mrs) : BIG MAX <| SUM r | r <- rects xs |>") 80 80 81 81 switchDispatching(false) 82 82 println("without optimization...")

