<commit_before>cdef extern from "mailbox.h":
  int mbox_open()
  mbox_close(int mb)


cdef extern from "gpu_fft.h":
  cdef struct GPU_FFT_COMPLEX:
    float re, im

  cdef struct GPU_FFT:
    GPU_FFT_COMPLEX* input
    GPU_FFT_COMPLEX* output
    int mb, step
    unsigned timeout, noflush, handle, size, vc_msg

  int gpu_fft_prepare(
      int mb,         # mailbox file_desc
      int log2_N,     # log2(FFT_length) = 8...17
      int direction,  # GPU_FFT_FWD: fft(); GPU_FFT_REV: ifft()
      int jobs,       # number of transforms in batch
      GPU_FFT **fft)

  unsigned gpu_fft_execute(GPU_FFT *info)
  void gpu_fft_release(GPU_FFT *info)<commit_msg>start of class interface.<commit_after>cdef extern from "mailbox.h":
  int mbox_open()
  void mbox_close(int mb)

cdef extern from "gpu_fft.h":
  cdef struct GPU_FFT_COMPLEX:
    float re, im

  cdef struct GPU_FFT:
    GPU_FFT_COMPLEX* input
    GPU_FFT_COMPLEX* output
    int mb, step
    unsigned timeout, noflush, handle, size, vc_msg

  int gpu_fft_prepare(
      int mb,         # mailbox file_desc
      int log2_N,     # log2(FFT_length) = 8...17
      int direction,  # GPU_FFT_FWD: fft(); GPU_FFT_REV: ifft()
      int jobs,       # number of transforms in batch
      GPU_FFT **fft)

  unsigned gpu_fft_execute(GPU_FFT *info)
  void gpu_fft_release(GPU_FFT *info)


cdef class GpuFft:
  cdef GPU_FFT* thisptr
  cdef int mb

  def __cinit__(self, int log_size, is_forward=True, int jobs=10):
    cdef int forward
    if is_forward:
      forward = 1
    else:
      forward = 0

    assert 8 <= log_size <= 17, 'log_size must be between 8 and 17'
    self.mb = mbox_open()
    gpu_fft_prepare(self.mb, log_size, forward, jobs, &self.thisptr)

  def __dealloc__(self):
    gpu_fft_release(self.thisptr)
    mbox_close(self.mb)
{'fraction_non_alphanumeric': 0.08690807799442897, 'fraction_numerical': 0.011142061281337047, 'mean_word_length': 3.045045045045045, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, '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': '7098834', 'n_tokens_mistral': 722, 'n_tokens_neox': 690, 'n_words': 181}