void shutdown_and_launch(void) { #ifdef NETRPC_ENABLE netrpc_shutdown(); #endif if (tftp) tftp_remove(tftp); net_shutdown(); mm_shutdown(); kernel_launch(); }
unsigned int add_two_vectors_gpu ( unsigned int n, int * a, int * b, int * c ) { int err = -1; /* get the GPU id */ cl_platform_id gpu_id = get_gpu_id( &err ); if( err ) { return ( 0 ); } /* get the device id */ cl_device_id dev_id = get_dev_id( gpu_id, &err ); if( err ) { return ( 0 ); } /* create the context using dev_id */ cl_context context = create_context( dev_id, &err ); if( err ) { return ( 0 ); } /* create a list to hold the commands to be executed by GPU */ cl_command_queue cmd_queue = create_cmd_queue ( dev_id, context, &err ); if( err ) { return ( 0 ); } /* create a kernel */ cl_kernel kernel; /* load the kernel ``kernel.cl'' with name ``vectors_kernel''*/ kernel = load_kernel ( "kernel.cl", "vectors_kernel", dev_id, context, &err ); if( err ) { return ( 0 ); } /* run the kernel */ if( ! ( kernel_launch ( kernel, context, cmd_queue, n, a, b, c ) ) ) return (0); clReleaseContext ( context ); clReleaseCommandQueue ( cmd_queue ); clReleaseKernel ( kernel ); return ( 1 ); }
unsigned int gapmis_one_to_many_opt_gpu ( const char * p1, const char ** t, const struct gapmis_params * in, struct gapmis_align * out ) { const char * p[] = { p1, NULL}; if ( in -> scoring_matrix > 1 ) { errno = MATRIX; return ( 0 ); } unsigned int pats = get_number_of_sequences (p); unsigned int txts = get_number_of_sequences (t); unsigned int maxPatLen = get_max_length (pats, p); unsigned int minTxtLen = get_min_length (txts, t); if (check_sequences(pats,p,in->scoring_matrix)==0) { errno = BADCHAR; return ( 0 ); } if (check_sequences(txts,t,in->scoring_matrix)==0) { errno = BADCHAR; return ( 0 ); } if(maxPatLen > minTxtLen) { errno = LENGTH; return ( 0 ); } if ( in -> max_gap >= minTxtLen ) { errno = MAXGAP; return ( 0 ); } int err = -1; /* get the GPU id */ cl_platform_id gpu_id = get_gpu_id(&err); if(err) { errno = NOGPU; return ( 0 ); } /* get the device id */ cl_device_id dev_id = get_dev_id(gpu_id, &err); if(err) { errno = NOGPU; return ( 0 ); } /* create the context using dev_id */ cl_context context = create_context(dev_id, &err); if(err) { errno = GPUERROR; return ( 0 ); } /* create a list with the commands to be executed by GPU */ cl_command_queue cmd_queue = create_cmd_queue (dev_id, context, &err); if(err) { errno = GPUERROR; return ( 0 ); } /* create a kernel */ cl_kernel kernel; /* load the kernel ``kernel_dna.cl'' with name ``gapmis_kernel''*/ if(in->scoring_matrix==0) kernel = load_kernel ("kernel_dna.cl", "gapmis_kernel", dev_id, context, &err); else kernel = load_kernel ("kernel_pro.cl", "gapmis_kernel", dev_id, context, &err); if(err) { errno = KERNEL; return ( 0 ); } const unsigned int patGroupSize = 1; const unsigned int txtGroupSize = 768; unsigned int i, j; unsigned int patGroups = get_number_of_groups (pats, patGroupSize); unsigned int txtGroups = get_number_of_groups (txts, txtGroupSize); const char * groupPatterns[patGroupSize+1]; set_null (groupPatterns, patGroupSize+1); const char * groupTexts[txtGroupSize+1]; set_null (groupTexts, txtGroupSize+1); float * groupScores; groupScores = calloc (patGroupSize*txtGroupSize, sizeof(float) ); int groupMatch [patGroupSize]; float groupMatchScores [patGroupSize]; set_invalid(groupMatch,patGroupSize); set_minimum(groupMatchScores,patGroupSize); for(i=0;i<patGroups;i++) { set_null (groupPatterns, patGroupSize+1); initialize_pointers (groupPatterns,i,patGroupSize,p,pats); set_invalid(groupMatch,patGroupSize); set_minimum(groupMatchScores,patGroupSize); for(j=0;j<txtGroups;j++) { set_null (groupTexts, txtGroupSize+1); initialize_pointers (groupTexts,j,txtGroupSize,t,txts); if( ! ( kernel_launch (kernel, context, cmd_queue, groupPatterns, groupTexts, in, groupScores) )) return ( 0 ); update_group_match (groupScores,groupMatch,groupMatchScores,patGroupSize,txtGroupSize, pats, txts, i, j); } for(j=0;j<patGroupSize;j++) { if(i*patGroupSize+j<pats) { groupPatterns[0] = p[i*patGroupSize+j]; groupPatterns[1] = NULL; groupTexts[0] = t[groupMatch[j]]; groupTexts[1] = NULL; if( !( kernel_launch_l (kernel, context, cmd_queue, groupPatterns, groupTexts, in, groupScores,&out[i*patGroupSize+j] ) ) ) return ( 0 ); } } } free ( groupScores ); clReleaseContext ( context ); clReleaseCommandQueue ( cmd_queue ); clReleaseKernel(kernel); return ( 1 ); }
int main(void) { int res; udelay(2000000); debug_init(); printf("\n\nBootOS Stage 2 starting.\n"); printf("Waiting for thread 1...\n"); while(!_thread1_active); printf("Thread 1 is alive, all systems go.\n"); exceptions_init(); lv2_cleanup(); mm_init(); #ifdef USE_NETWORK net_init(); gstate = STATE_START; while(1) { net_poll(); if(sequence()) break; } #endif #ifdef AUTO_HDD static FATFS fatfs; DSTATUS stat; stat = disk_initialize(0); if (stat & ~STA_PROTECT) fatal("disk_initialize() failed"); printf("Mounting filesystem...\n"); res = f_mount(0, &fatfs); if (res != FR_OK) fatal("f_mount() failed"); printf("Reading kboot.conf...\n"); res = readfile("/kboot.conf", conf_buf, MAX_KBOOTCONF_SIZE-1); if (res <= 0) { printf("Could not read kboot.conf (%d), panicking\n", res); lv1_panic(0); } conf_buf[res] = 0; kbootconf_parse(); if (conf.num_kernels == 0) { printf("No kernels found in configuration file. Panicing...\n"); lv1_panic(0); } boot_entry = conf.default_idx; printf("Starting to boot '%s'\n", conf.kernels[boot_entry].label); printf("Loading kernel (%s)...\n", conf.kernels[boot_entry].kernel); kernel_buf = mm_highmem_freestart(); res = readfile(conf.kernels[boot_entry].kernel, kernel_buf, mm_highmem_freesize()); if (res <= 0) { printf("Could not read kernel (%d), panicking\n", res); lv1_panic(0); } printf("Kernel size: %d\n", res); if (kernel_load(kernel_buf, res) != 0) { printf("Failed to load kernel. Rebooting...\n"); lv1_panic(1); } if (conf.kernels[boot_entry].initrd && conf.kernels[boot_entry].initrd[0]) { initrd_buf = mm_highmem_freestart(); res = readfile(conf.kernels[boot_entry].initrd, initrd_buf, mm_highmem_freesize()); if (res <= 0) { printf("Could not read initrd (%d), panicking\n", res); lv1_panic(0); } printf("Initrd size: %d\n", res); mm_highmem_reserve(res); kernel_set_initrd(initrd_buf, res); } kernel_build_cmdline(conf.kernels[boot_entry].parameters, conf.kernels[boot_entry].root); f_mount(0, NULL); disk_shutdown(0); mm_shutdown(); kernel_launch(); #endif printf("Loading embedded kernel...\n"); kernel_buf = mm_highmem_freestart(); printf("Decompressing kernel to %lX...\n", (u64) kernel_buf); res = unzpipe (kernel_buf, __vmlinux, &kernel_sz); if (res) { printf("Cannot decompress kernel, error %d.\n", res); lv1_panic(1); } printf("Kernel size: %ld\n", kernel_sz); if (kernel_load(kernel_buf, kernel_sz) != 0) { printf("Failed to load embedded kernel. Rebooting...\n"); lv1_panic(1); } kernel_build_cmdline("video=ps3fb:mode:0 panic=5", "/dev/sda1"); shutdown_and_launch(); printf("End of main() reached! Rebooting...\n"); lv1_panic(1); return 0; }