Ejemplo n.º 1
0
int opencl_run_kernel(char* fileName) {
  size_t work_dim[2];
  char entrada[32];
  float *Matriz;
  int i, j, numberShift = 0;

  Matriz = loadMatrix(fileName);
  prepare_kernel();
  work_dim[0] = sizeR;
  work_dim[1] = sizeC;   
  
  while (1) {
    printf("Digite 0 para column-shift, 1 para row-shift ou q para sair:\n");
    gets(entrada);
    if (strcmp(entrada, "q") == 0 ) break;
    axis = atoi(entrada);
    printf("Digite o número de shifts:\n");
    gets(entrada);
    numberShift = atoi(entrada);
    clEnqueueWriteBuffer(queue, opclMatrizInicial, CL_TRUE, 0, sizeOfMatrix, Matriz, 0, NULL, &event);
    clEnqueueWriteBuffer(queue, shifts, CL_TRUE, 0, sizeof(int), &numberShift, 0, NULL, &event);
    clEnqueueWriteBuffer(queue, axisShift, CL_TRUE, 0, sizeof(int), &axis, 0, NULL, &event);
    clEnqueueNDRangeKernel(queue, kernel, 2, NULL, work_dim, NULL, 0, NULL, &event);
    clReleaseEvent(event);
    clFinish(queue);

    if( clEnqueueReadBuffer(queue, opclMatriz, CL_TRUE, 0, sizeOfMatrix, Matriz, 0, NULL, &event) 
        != CL_SUCCESS ) printf("ERRROROOO\n");
    clReleaseEvent(event);

    printMatrix(Matriz, "Matriz Shift-Row:");
  }
  free(Matriz);
  return 1;
}
Ejemplo n.º 2
0
/**
 * start_darwin
 *
 * Start the Darwin kernel.
 */
void start_darwin(void)
{
    boot_args *args;
    kernel_start *start_routine;

    /* 
     * Initialize the kernel memory region. 
     *
     * The kernel is always mapped to eDRAM + PAGE_SIZE. This is done
     * for sleep support. (eventually.)
     */
    kernel_region.pos = kernel_region.base = (gBootArgs.physBase + 0x1000);

    /* XXX: Zero out beginning of RAM. */
    printf("preparing system...\n");
    bzero((void *)gBootArgs.physBase, (32 * 1024 * 1024));

    /* Initialize boot-args. */
    assert(prepare_boot_args());

    /* Map kernel. */
    assert(prepare_kernel());

    /* Map device tree. */
    assert(prepare_devicetree());

    /* Enter ramdisk into /chosen/memory-map and flatten. */
    assert(prepare_devicetree_stage2());

    /* Copy boot-args over to kernel region. */
    assert((args = prepare_finalized_boot_args()) != NULL);

    /* Jump to the kernel. */
    start_routine = (kernel_start *) kernel_entrypoint;
    printf
        ("kernel prepped at 0x%08x, transferring control out of booter now!\n",
         start_routine);

    /* _locore_jump_to */
    _locore_jump_to(start_routine, (void *)args);

    panic("Should never return from here.\n");
    return;
}