<commit_before>#include "_C_occa.h"

//---[ Globals & Flags ]----------------
static PyObject* py_occaSetVerboseCompilation(PyObject *self, PyObject *args){
  int value;

  if(!PyArg_ParseTuple(args, "i", &value))
    return NULL;

  occaSetVerboseCompilation(value);

  return Py_None;
}
//======================================

//----[ Background Device ]-------------
//  |---[ Device ]----------------------
static PyObject* py_occaSetDevice(PyObject *self, PyObject *args){
  occaDevice device;

  if(!PyArg_ParseTuple(args, "n", &device))
    return NULL;

  occaSetDevice(device);

  return Py_None;
}

static PyObject* py_occaSetDeviceFromInfo(PyObject *self, PyObject *args){
  const char *infos;

  if(!PyArg_ParseTuple(args, "s", &infos))
    return NULL;

  occaSetDeviceFromInfo(infos);

  return Py_None;
}

static PyObject* py_occaGetCurrentDevice(PyObject *self, PyObject *args){
  occaDevice device = occaGetCurrentDevice();

  return PyLong_FromVoidPtr(device);
}

static PyObject* py_occaSetCompiler(PyObject *self, PyObject *args){
  const char *compiler;

  if(!PyArg_ParseTuple(args, "s", &compiler))
    return NULL;

  occaSetCompiler(compiler);

  return Py_None;
}

static PyObject* py_occaSetCompilerEnvScript(PyObject *self, PyObject *args){
  const char *compilerEnvScript;

  if(!PyArg_ParseTuple(args, "s", &compilerEnvScript))
    return NULL;

  occaSetCompilerEnvScript(compilerEnvScript);

  return Py_None;
}

static PyObject* py_occaSetCompilerFlags(PyObject *self, PyObject *args){
  const char *compilerFlags;

  if(!PyArg_ParseTuple(args, "s", &compilerFlags))
    return NULL;

  occaSetCompilerFlags(compilerFlags);

  return Py_None;
}

static PyObject* py_occaGetCompiler(PyObject *self, PyObject *args){
  const char *compiler = occaGetCompiler();
  return PyString_FromString(compiler);
}

static PyObject* py_occaGetCompilerEnvScript(PyObject *self, PyObject *args){
  const char *compilerEnvScript = occaGetCompilerEnvScript();
  return PyString_FromString(compilerEnvScript);
}

static PyObject* py_occaGetCompilerFlags(PyObject *self, PyObject *args){
  const char *compilerFlags = occaGetCompilerFlags();
  return PyString_FromString(compilerFlags);
}

static PyObject* py_occaFlush(PyObject *self, PyObject *args){
  occaFlush();

  return Py_None;
}

static PyObject* py_occaFinish(PyObject *self, PyObject *args){
  occaFinish();

  return Py_None;
}

/* static PyObject* py_occaWaitFor(PyObject *self, PyObject *args){ */
/*   occaStreamTag tag; */

/*   if(!PyArg_ParseTuple(args, "n", &tag)) */
/*     return NULL; */

/*   occaWaitFor(tag); */

/*   return Py_None; */
/* } */

static PyObject* py_occaCreateStream(PyObject *self, PyObject *args){
  occaStream stream = occaCreateStream();

  return PyLong_FromVoidPtr(stream);
}

static PyObject* py_occaGetStream(PyObject *self, PyObject *args){
  occaStream stream = occaGetStream();

  return PyLong_FromVoidPtr(stream);
}

static PyObject* py_occaSetStream(PyObject *self, PyObject *args){
  occaStream stream;

  if(!PyArg_ParseTuple(args, "n", &stream))
    return NULL;

  occaSetStream(stream);

  return Py_None;
}

static PyObject* py_occaWrapStream(PyObject *self, PyObject *args){
  occaStream stream;
  void *handle;

  if(!PyArg_ParseTuple(args, "n", &handle))
    return NULL;

  stream = occaWrapStream(handle);

  return PyLong_FromVoidPtr(stream);
}

/* static PyObject* py_occaTagStream(PyObject *self, PyObject *args){ */
/*   occaStreamTag tag = occaTagStream(); */

/*   return PyLong_FromVoidPtr(tag); */
/* } */

//  |===================================

//  |---[ Kernel ]----------------------
static PyObject* py_occaBuildKernel(PyObject *self, PyObject *args){
  const char *str, *functionName;
  occaKernelInfo *kInfo;

  if(!PyArg_ParseTuple(args, "ssn", &str, &functionName, &kInfo))
    return NULL;

  occaKernel kernel = occaBuildKernel(str, functionName, kInfo);

  return PyLong_FromVoidPtr(kernel);
}

static PyObject* py_occaBuildKernelFromSource(PyObject *self, PyObject *args){
  const char *filename, *functionName;
  occaKernelInfo *kInfo;

  if(!PyArg_ParseTuple(args, "ssn", &filename, &functionName, &kInfo))
    return NULL;

  occaKernel kernel = occaBuildKernelFromSource(filename, functionName, kInfo);

  return PyLong_FromVoidPtr(kernel);
}

static PyObject* py_occaBuildKernelFromString(PyObject *self, PyObject *args){
  const char *filename, *functionName, *language;
  occaKernelInfo *kInfo;
  occaKernel kernel;

  if(!PyArg_ParseTuple(args, "sssn", &filename, &functionName, &kInfo, &language))
    return NULL;

  if(strcmp(language, "OFL") == 0)
    kernel = occaBuildKernelFromSource(filename, functionName, kInfo, occaUsingOFL);
  else if(strcmp(language, "Native") == 0)
    kernel = occaBuildKernelFromSource(filename, functionName, kInfo, occaUsingNative);
  else
    kernel = occaBuildKernelFromSource(filename, functionName, kInfo, occaUsingOKL);

  return PyLong_FromVoidPtr(kernel);
}

static PyObject* py_occaBuildKernelFromBinary(PyObject *self, PyObject *args){
  const char *filename, *functionName;

  if(!PyArg_ParseTuple(args, "ss", &filename, &functionName))
    return NULL;

  occaKernel kernel = occaBuildKernelFromBinary(filename, functionName);

  return PyLong_FromVoidPtr(kernel);
}

static PyObject* py_occaBuildKernelFromLoopy(PyObject *self, PyObject *args){
  const char *filename, *functionName;
  occaKernelInfo *kInfo;

  if(!PyArg_ParseTuple(args, "ssn", &filename, &functionName, &kInfo))
    return NULL;

  occaKernel kernel = occaBuildKernelFromLoopy(filename, functionName, kInfo);

  return PyLong_FromVoidPtr(kernel);
}<commit_msg>[Python] 33% [2]<commit_after>#include "_C_occa.h"

//---[ Globals & Flags ]----------------
static PyObject* py_occaSetVerboseCompilation(PyObject *self, PyObject *args){
  int value;

  if(!PyArg_ParseTuple(args, "i", &value))
    return NULL;

  occaSetVerboseCompilation(value);

  return Py_None;
}
//======================================

//----[ Background Device ]-------------
//  |---[ Device ]----------------------
static PyObject* py_occaSetDevice(PyObject *self, PyObject *args){
  occaDevice device;

  if(!PyArg_ParseTuple(args, "n", &device))
    return NULL;

  occaSetDevice(device);

  return Py_None;
}

static PyObject* py_occaSetDeviceFromInfo(PyObject *self, PyObject *args){
  const char *infos;

  if(!PyArg_ParseTuple(args, "s", &infos))
    return NULL;

  occaSetDeviceFromInfo(infos);

  return Py_None;
}

static PyObject* py_occaGetCurrentDevice(PyObject *self, PyObject *args){
  occaDevice device = occaGetCurrentDevice();

  return PyLong_FromVoidPtr(device);
}

static PyObject* py_occaSetCompiler(PyObject *self, PyObject *args){
  const char *compiler;

  if(!PyArg_ParseTuple(args, "s", &compiler))
    return NULL;

  occaSetCompiler(compiler);

  return Py_None;
}

static PyObject* py_occaSetCompilerEnvScript(PyObject *self, PyObject *args){
  const char *compilerEnvScript;

  if(!PyArg_ParseTuple(args, "s", &compilerEnvScript))
    return NULL;

  occaSetCompilerEnvScript(compilerEnvScript);

  return Py_None;
}

static PyObject* py_occaSetCompilerFlags(PyObject *self, PyObject *args){
  const char *compilerFlags;

  if(!PyArg_ParseTuple(args, "s", &compilerFlags))
    return NULL;

  occaSetCompilerFlags(compilerFlags);

  return Py_None;
}

static PyObject* py_occaGetCompiler(PyObject *self, PyObject *args){
  const char *compiler = occaGetCompiler();
  return PyString_FromString(compiler);
}

static PyObject* py_occaGetCompilerEnvScript(PyObject *self, PyObject *args){
  const char *compilerEnvScript = occaGetCompilerEnvScript();
  return PyString_FromString(compilerEnvScript);
}

static PyObject* py_occaGetCompilerFlags(PyObject *self, PyObject *args){
  const char *compilerFlags = occaGetCompilerFlags();
  return PyString_FromString(compilerFlags);
}

static PyObject* py_occaFlush(PyObject *self, PyObject *args){
  occaFlush();

  return Py_None;
}

static PyObject* py_occaFinish(PyObject *self, PyObject *args){
  occaFinish();

  return Py_None;
}

/* static PyObject* py_occaWaitFor(PyObject *self, PyObject *args){ */
/*   occaStreamTag tag; */

/*   if(!PyArg_ParseTuple(args, "n", &tag)) */
/*     return NULL; */

/*   occaWaitFor(tag); */

/*   return Py_None; */
/* } */

static PyObject* py_occaCreateStream(PyObject *self, PyObject *args){
  occaStream stream = occaCreateStream();

  return PyLong_FromVoidPtr(stream);
}

static PyObject* py_occaGetStream(PyObject *self, PyObject *args){
  occaStream stream = occaGetStream();

  return PyLong_FromVoidPtr(stream);
}

static PyObject* py_occaSetStream(PyObject *self, PyObject *args){
  occaStream stream;

  if(!PyArg_ParseTuple(args, "n", &stream))
    return NULL;

  occaSetStream(stream);

  return Py_None;
}

static PyObject* py_occaWrapStream(PyObject *self, PyObject *args){
  occaStream stream;
  void *handle;

  if(!PyArg_ParseTuple(args, "n", &handle))
    return NULL;

  stream = occaWrapStream(handle);

  return PyLong_FromVoidPtr(stream);
}

/* static PyObject* py_occaTagStream(PyObject *self, PyObject *args){ */
/*   occaStreamTag tag = occaTagStream(); */

/*   return PyLong_FromVoidPtr(tag); */
/* } */

//  |===================================

//  |---[ Kernel ]----------------------
static PyObject* py_occaBuildKernel(PyObject *self, PyObject *args){
  const char *str, *functionName;
  occaKernelInfo *kInfo;

  if(!PyArg_ParseTuple(args, "ssn", &str, &functionName, &kInfo))
    return NULL;

  occaKernel kernel = occaBuildKernel(str, functionName, kInfo);

  return PyLong_FromVoidPtr(kernel);
}

static PyObject* py_occaBuildKernelFromSource(PyObject *self, PyObject *args){
  const char *filename, *functionName;
  occaKernelInfo *kInfo;

  if(!PyArg_ParseTuple(args, "ssn", &filename, &functionName, &kInfo))
    return NULL;

  occaKernel kernel = occaBuildKernelFromSource(filename, functionName, kInfo);

  return PyLong_FromVoidPtr(kernel);
}

static PyObject* py_occaBuildKernelFromString(PyObject *self, PyObject *args){
  const char *filename, *functionName, *language;
  occaKernelInfo *kInfo;
  occaKernel kernel;

  if(!PyArg_ParseTuple(args, "sssn", &filename, &functionName, &kInfo, &language))
    return NULL;

  if(strcmp(language, "OFL") == 0)
    kernel = occaBuildKernelFromString(filename, functionName, kInfo, occaUsingOFL);
  else if(strcmp(language, "Native") == 0)
    kernel = occaBuildKernelFromString(filename, functionName, kInfo, occaUsingNative);
  else
    kernel = occaBuildKernelFromString(filename, functionName, kInfo, occaUsingOKL);

  return PyLong_FromVoidPtr(kernel);
}

static PyObject* py_occaBuildKernelFromBinary(PyObject *self, PyObject *args){
  const char *filename, *functionName;

  if(!PyArg_ParseTuple(args, "ss", &filename, &functionName))
    return NULL;

  occaKernel kernel = occaBuildKernelFromBinary(filename, functionName);

  return PyLong_FromVoidPtr(kernel);
}

static PyObject* py_occaBuildKernelFromLoopy(PyObject *self, PyObject *args){
  const char *filename, *functionName;
  occaKernelInfo *kInfo;

  if(!PyArg_ParseTuple(args, "ssn", &filename, &functionName, &kInfo))
    return NULL;

  occaKernel kernel = occaBuildKernelFromLoopy(filename, functionName, kInfo);

  return PyLong_FromVoidPtr(kernel);
}
{'fraction_non_alphanumeric': 0.1447566705079337, 'fraction_numerical': 0.0006205123659250067, 'mean_word_length': 5.202308960967565, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5407985', 'n_tokens_mistral': 3682, 'n_tokens_neox': 3725, 'n_words': 812}