-- -----------------------------------------------------------------------------

kernelHead :: Name -> Env -> SymbolTable -> String
kernelHead kname env ct = header 
    where header  = "__global__ static void " ++ kname ++ "(" ++ 
                    inputs ++"char *gbase){\n" ++ 
                    sbase ++ tid ++ lengths
          tid     = "const int tid = threadIdx.x;\n"
          sbase   = "extern __shared__ char sbase[] __attribute__ ((aligned(4)));\n" 
          ls (x,y)= "const int " ++ x ++ 
                    " __attribute__ ((unused)) = " ++ show y ++ ";\n"
          lengths = unwords $ map ls env
          inputs  = unwords (map (\x -> (ptrStr ((elemType . typeof x) ct)) ++ x++",") sources)
          sources = filter (\x -> "source" `isPrefixOf` x) (Map.keys ct) 
kernelHead :: Name -> Env -> SymbolTable -> String
kernelHead kname env ct = header 
    where header  = "__global__ static void " ++ kname ++ "(" ++ 
                    inputs ++"char *gbase){\n" ++ 
                    sbase ++ tid ++ lengths
          tid     = "const int tid = threadIdx.x;\n"
          sbase   = "extern __shared__ char sbase[] __attribute__ ((aligned(4)));\n" 
          ls (x,y)= "const int " ++ x ++ 
                    " __attribute__ ((unused)) = " ++ show y ++ ";\n"
          lengths = unwords $ map ls env
          inputs  = unwords (map (\x -> (ptrStr ((elemType . typeof x) ct)) ++ x++",") sources)
          sources = filter (\x -> "source" `isPrefixOf` x) (Map.keys ct) 
kernelHead kname env ct = header 
    where header  = "__global__ static void " ++ kname ++ "(" ++ 
                    inputs ++"char *gbase){\n" ++ 
                    sbase ++ tid ++ lengths
          tid     = "const int tid = threadIdx.x;\n"
          sbase   = "extern __shared__ char sbase[] __attribute__ ((aligned(4)));\n" 
          ls (x,y)= "const int " ++ x ++ 
                    " __attribute__ ((unused)) = " ++ show y ++ ";\n"
          lengths = unwords $ map ls env
          inputs  = unwords (map (\x -> (ptrStr ((elemType . typeof x) ct)) ++ x++",") sources)
          sources = filter (\x -> "source" `isPrefixOf` x) (Map.keys ct) 