Exemplo n.º 1
0
int main (int argc, char* argv[]) {

   /* Start GL processing */
   init_gl(argc, argv);

   /* Initialize CL data structures */
   init_cl();

   /* Create CL and GL data objects */
   configure_shared_data();

   /* Execute kernel */
   execute_kernel();

   /* Set callback functions */
   glutDisplayFunc(display);
   glutReshapeFunc(reshape);   

   /* Start processing loop */
   glutMainLoop();

   /* Deallocate OpenCL resources */
   clReleaseMemObject(in_texture);
   clReleaseMemObject(out_buffer);
   clReleaseKernel(kernel);
   clReleaseCommandQueue(queue);
   clReleaseProgram(program);
   clReleaseContext(context);

   /* Deallocate OpenGL resources */
   glDeleteBuffers(2, vbo);

   return 0;
}
Exemplo n.º 2
0
int ldr_main(struct multiboot_info* boot_info, uint32 krnldr_size_bytes)
{
	SetColor(MakeColor(DARK_BLUE, WHITE));
	ClearScreen();

	if (krnldr_size_bytes > 40 KB)
		PANIC("Kernel Loader is too large");

	init_kallocations(KRN_LDR_BASE + krnldr_size_bytes, KRN_LDR_LIMIT);

	Print("Initializing descriptor tables.");

	INT_OFF;
	init_isr();
	init_descriptor_tables();
	init_pic();
	INT_ON;

	init_pit_timer(50, timer_callback);

	struct kernel_info* k_info = kalloc(sizeof(struct kernel_info));

	//setup AHCI
	HBA_MEM_t* abar = PCIFindAHCI();

	// initialize basic virtual memory
	vmmngr_initialize();

	uint32 ahci_base = kalloc_get_ptr() + 1024 - (uint32)kalloc_get_ptr() % 1024;
	init_ahci(abar, ahci_base);

	uint32 start, _length, position = 0;
	fsysSimpleFind("MeOs.exe", 1, &_length, &start);

	if (start == (uint32)-1 && _length == 0)
		PANIC("Kernel module could not be found!");

	while (position <= _length)
	{
		fsysSimpleRead(start + position / 512, 4096, KERNEL_BASE + position);
		position += 4096;
	}

	// after all the loading is done... enable paging
	vmmngr_paging_enable(true);

	k_info->kernel_size = _length;
	k_info->isr_handlers = interrupt_handlers;
	k_info->gdt_base = gdt_entries;
	k_info->idt_base = idt_entries;

	printfln("Executing kernel\0");
	execute_kernel(boot_info, k_info);

	ClearScreen();
	_asm cli
	_asm hlt
}
Exemplo n.º 3
0
void display(void) {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   execute_kernel();

   glBindVertexArray(vao);
   glDrawArrays(GL_LINE_LOOP, 0, NUM_VERTICES);

   tick += 0.0001f;

   glBindVertexArray(0);
   glutSwapBuffers();
   glutPostRedisplay();
}
Exemplo n.º 4
0
static void
run_benchmark (SetupQueueFunc setup,
               const char *fmt,
               Data *data)
{
    GTimer *timer;

    setup (data);
    timer = g_timer_new ();
    execute_kernel (data, N_ITERATIONS);
    g_timer_stop (timer);
    g_print (fmt, g_timer_elapsed (timer, NULL));
    g_timer_destroy (timer);
    teardown_queues (data);
}
Exemplo n.º 5
0
void kernel(int n, int m, float ** A, float b) {
  struct kernel_t * kernel = build_kernel(0);

  kernel->data[0] = &(A[0][0]);

  kernel->scalar[0] = &(b);

  kernel->param[0] = n;
  kernel->param[1] = m;

  kernel->loops[0].lower = 0;
  kernel->loops[0].upper = n-1;
  kernel->loops[0].stride = 1;

  kernel->loops[1].lower = 0;
  kernel->loops[1].upper = m-1;
  kernel->loops[1].stride = 1;

  execute_kernel(kernel);
}