<commit_before>use opencl::hl::{Device, Context, CommandQueue};
use opencl::util::create_compute_context;

pub struct CL {
  pub device: Device,
  pub context: Context,
  pub queue: CommandQueue,
}

impl CL {
  pub unsafe fn new() -> CL {
    let (device, context, queue) = create_compute_context().unwrap();
    CL {
      device: device,
      context: context,
      queue: queue,
    }
  }
}<commit_msg>Smarter and more transparent OpenCL device selection.<commit_after>use opencl::hl;
use opencl::hl::{Device, Context, CommandQueue};

pub struct CL {
  pub device: Device,
  pub context: Context,
  pub queue: CommandQueue,
}

impl CL {
  pub unsafe fn new() -> CL {
    for platform in hl::get_platforms().iter() {
      debug!("Found OpenCL platform: {}", platform.name());
      debug!("Available devices:");
      let devices = platform.get_devices();
      for device in devices.into_iter() {
        debug!("  {}", device.name());
        let context = device.create_context();
        let queue = context.create_command_queue(&device);

        return CL {
          device: device,
          context: context,
          queue: queue,
        };
      }
    }

    panic!("Couldn't find an OpenCL device.");
  }
}
{'fraction_non_alphanumeric': 0.13306122448979593, 'fraction_numerical': 0.0, 'mean_word_length': 2.9044585987261144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2107221', 'n_tokens_mistral': 361, 'n_tokens_neox': 365, 'n_words': 106}