{-# LANGUAGE TemplateHaskell #-}

-- | Code snippets used by the C backends.
module Futhark.CodeGen.RTS.C
  ( atomicsH,
    chaselevH,
    cudaH,
    freeListH,
    halfH,
    lockH,
    openclH,
    scalarF16H,
    scalarH,
    schedulerH,
    serverH,
    timingH,
    tuningH,
    utilH,
    valuesH,
  )
where

import Data.FileEmbed
import qualified Data.Text as T

-- We mark everything here NOINLINE so that the dependent modules
-- don't have to be recompiled just because we change the RTS files.

-- | @rts/c/atomics.h@
atomicsH :: T.Text
atomicsH :: Text
atomicsH = $(embedStringFile "rts/c/atomics.h")
{-# NOINLINE atomicsH #-}

-- | @rts/c/chaselev.h@
chaselevH :: T.Text
chaselevH :: Text
chaselevH = $(embedStringFile "rts/c/chaselev.h")
{-# NOINLINE chaselevH #-}

-- | @rts/c/cuda.h@
cudaH :: T.Text
cudaH :: Text
cudaH = $(embedStringFile "rts/c/cuda.h")
{-# NOINLINE cudaH #-}

-- | @rts/c/free_list.h@
freeListH :: T.Text
freeListH :: Text
freeListH = $(embedStringFile "rts/c/free_list.h")
{-# NOINLINE freeListH #-}

-- | @rts/c/half.h@
halfH :: T.Text
halfH :: Text
halfH = $(embedStringFile "rts/c/half.h")
{-# NOINLINE halfH #-}

-- | @rts/c/lock.h@
lockH :: T.Text
lockH :: Text
lockH = $(embedStringFile "rts/c/lock.h")
{-# NOINLINE lockH #-}

-- | @rts/c/opencl.h@
openclH :: T.Text
openclH :: Text
openclH = $(embedStringFile "rts/c/opencl.h")
{-# NOINLINE openclH #-}

-- | @rts/c/scalar_f16.h@
scalarF16H :: T.Text
scalarF16H :: Text
scalarF16H = $(embedStringFile "rts/c/scalar_f16.h")
{-# NOINLINE scalarF16H #-}

-- | @rts/c/scalar.h@
scalarH :: T.Text
scalarH :: Text
scalarH = $(embedStringFile "rts/c/scalar.h")
{-# NOINLINE scalarH #-}

-- | @rts/c/scheduler.h@
schedulerH :: T.Text
schedulerH :: Text
schedulerH = $(embedStringFile "rts/c/scheduler.h")
{-# NOINLINE schedulerH #-}

-- | @rts/c/server.h@
serverH :: T.Text
serverH :: Text
serverH = $(embedStringFile "rts/c/server.h")
{-# NOINLINE serverH #-}

-- | @rts/c/timing.h@
timingH :: T.Text
timingH :: Text
timingH = $(embedStringFile "rts/c/timing.h")
{-# NOINLINE timingH #-}

-- | @rts/c/tuning.h@
tuningH :: T.Text
tuningH :: Text
tuningH = $(embedStringFile "rts/c/tuning.h")
{-# NOINLINE tuningH #-}

-- | @rts/c/util.h@
utilH :: T.Text
utilH :: Text
utilH = $(embedStringFile "rts/c/util.h")
{-# NOINLINE utilH #-}

-- | @rts/c/values.h@
valuesH :: T.Text
valuesH :: Text
valuesH = $(embedStringFile "rts/c/values.h")
{-# NOINLINE valuesH #-}