--  This file is part of seismic_acc_no_up.
--
--  seismic_acc_no_up 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 3 of the License, or
--  (at your option) any later version.
--
--  seismic_acc_no_up is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with seismic_acc_no_up.  If not, see <http://www.gnu.org/licenses/>.


{-# LANGUAGE FlexibleContexts, BangPatterns, ScopedTypeVariables#-}
{-# OPTIONS -Wall -fno-warn-missing-signatures -fno-warn-incomplete-patterns #-}

import Seismic
import System.Environment
import Data.Time(getCurrentTime, diffUTCTime)
import Data.Array.Accelerate.CUDA     as CUDA

main :: IO ()
main = do
  args <- getArgs
  case args of
       [t, x, y] -> go (read t::Int) (read x::Int)  (read y::Int)
       _         -> print usage

go !t !x !y = do
    let ppf = genPPF x y
    let apf = genAPF x y
    let vel = genVEL x y
    let pulse = genSeismicPulseVector t
    start <- getCurrentTime
    let !res = CUDA.run $ doNTimes ppf apf vel pulse t 0 x y
    end   <- getCurrentTime
    print $ diffUTCTime end start
    return ()

usage :: String
usage = "Usage: seismic_acc_no_up timeSteps xDim yDim"