<commit_before>{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module Futhark.CodeGen.Backends.PyOpenCL.Boilerplate
  ( openClInit
  , openClPrelude
  ) where

import Data.FileEmbed
import qualified Data.Text as T
import NeatInterpolation (text)

import Futhark.Representation.AST.Attributes.Constants (value)
import Futhark.CodeGen.OpenCL.Kernels
import Futhark.CodeGen.Backends.GenericPython.AST
import Futhark.Util.Pretty (pretty)

openClPrelude :: String
openClPrelude = $(embedStringFile "rts/python/opencl.py")

openClInit :: String -> String
openClInit assign = T.unpack [text|
self.ctx = get_prefered_context(interactive, platform_pref, device_pref)
self.queue = cl.CommandQueue(self.ctx)
self.device = self.ctx.get_info(cl.context_info.DEVICES)[0]
 # XXX: Assuming just a single device here.
platform_name = self.ctx.get_info(cl.context_info.DEVICES)[0].platform.name
device_type = self.device.type
lockstep_width = 1
$set_lockstep_width
max_tile_size = int(np.sqrt(self.device.max_work_group_size))
if (tile_size * tile_size > self.device.max_work_group_size):
  sys.stderr.write('Warning" Device limits tile size to {} (setting was {})\n'.format(max_tile_size, tile_size))
  tile_size = max_tile_size
self.group_size = group_size
self.num_groups = num_groups
self.tile_size = tile_size
if (len(fut_opencl_src) >= 0):
  program = cl.Program(self.ctx, fut_opencl_src).build(["-DFUT_BLOCK_DIM={}".format(FUT_BLOCK_DIM),<commit_msg>Should be a colon here.<commit_after>{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module Futhark.CodeGen.Backends.PyOpenCL.Boilerplate
  ( openClInit
  , openClPrelude
  ) where

import Data.FileEmbed
import qualified Data.Text as T
import NeatInterpolation (text)

import Futhark.Representation.AST.Attributes.Constants (value)
import Futhark.CodeGen.OpenCL.Kernels
import Futhark.CodeGen.Backends.GenericPython.AST
import Futhark.Util.Pretty (pretty)

openClPrelude :: String
openClPrelude = $(embedStringFile "rts/python/opencl.py")

openClInit :: String -> String
openClInit assign = T.unpack [text|
self.ctx = get_prefered_context(interactive, platform_pref, device_pref)
self.queue = cl.CommandQueue(self.ctx)
self.device = self.ctx.get_info(cl.context_info.DEVICES)[0]
 # XXX: Assuming just a single device here.
platform_name = self.ctx.get_info(cl.context_info.DEVICES)[0].platform.name
device_type = self.device.type
lockstep_width = 1
$set_lockstep_width
max_tile_size = int(np.sqrt(self.device.max_work_group_size))
if (tile_size * tile_size > self.device.max_work_group_size):
  sys.stderr.write('Warning: Device limits tile size to {} (setting was {})\n'.format(max_tile_size, tile_size))
  tile_size = max_tile_size
self.group_size = group_size
self.num_groups = num_groups
self.tile_size = tile_size
if (len(fut_opencl_src) >= 0):
  program = cl.Program(self.ctx, fut_opencl_src).build(["-DFUT_BLOCK_DIM={}".format(FUT_BLOCK_DIM),
{'fraction_non_alphanumeric': 0.11754855994641661, 'fraction_numerical': 0.0026791694574681848, 'mean_word_length': 6.1119047619047615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '250527', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1062, 'n_words': 195}