/*ARGSUSED*/ static int ctl_open(int using_stdin, int using_stdout) { init_X(); // dont know what this function does /* if (current_file != NULL) { current_file_info = get_midi_file_info(current_file, 1); printf("Opening info for %s\n", current_file); } else { printf("Current is NULL\n"); } */ ctl->opened = 1; return 0; }
int main(int ac, char **av) { pname = *av; /* parse the command line arguments */ while (--ac) { char *p = *++av; if (!strcmp(p, "-display") || !strcmp(p, "-disp")) { if (!av[1]) error("option `%s' expects a parameter", p); display = *++av, --ac; } else if (*p=='-') { error("unrecognised option `%s'", p); } } init_X(); run_X(); done_X(); return 0; }
int main(int argc, char **argv){ double time_io = 0, time_compute_build = 0, time_build = 0; double begin, end; // init begin = omp_get_wtime(); // io time load_arguements(argc, argv); read_body_file(); if(X_enable){ init_X(); } end = omp_get_wtime(); // io time time_io = end - begin; // distribute simulation parts begin = omp_get_wtime(); // compute time if(body_num < thread_num){ thread_num = body_num; } // simulate if(DEBUG){ printf("start simulation......\n"); } omp_set_num_threads(thread_num); next_bodies = new body_t[body_num]; #pragma omp parallel { // T times simulation for(int t=0; t<T; t++){ // build HB tree #pragma omp single { double b_begin, b_end; b_begin = omp_get_wtime(); // build time tree_clean(root); tree_get_range(); root = tree_create_node( body_max_x, body_min_x, body_max_y, body_min_y); for(int i=0; i<body_num; i++){ tree_insert_node(root, bodies+i); } b_end = omp_get_wtime(); // build time time_build += b_end - b_begin; } // next position #pragma omp for schedule(static) for(int n=0; n<body_num; n++){ next_bodies[n].p_x = bodies[n].p_x + bodies[n].v_x * interval; next_bodies[n].p_y = bodies[n].p_y + bodies[n].v_y * interval; } // next velocity #pragma omp for schedule(static) for(int n=0; n<body_num; n++){ double total_a_x = 0; double total_a_y = 0; tree_compute_a(&bodies[n], root, &total_a_x, &total_a_y); next_bodies[n].v_x = bodies[n].v_x + total_a_x * interval; next_bodies[n].v_y = bodies[n].v_y + total_a_y * interval; } // synchronize #pragma omp barrier // update bodies #pragma omp for schedule(static) for(int n=0; n<body_num; n++){ bodies[n] = next_bodies[n]; } // synchronize #pragma omp barrier // display #pragma omp single { if(X_enable){ update_window(); } } } } if(DEBUG){ printf("done\n"); } delete [] next_bodies; delete [] bodies; end = omp_get_wtime(); // compute time time_compute_build = end - begin; printf("( Thread , Step , Body , IO , Build , Compute , Total ) -> "); printf("( %d , %d , %d , %lf , %lf , %lf , %lf )\n", thread_num, T, body_num, time_io, time_build, time_compute_build - time_build, time_io + time_compute_build); return 0; }
int main(int argc, char **argv){ int i,j; /* initialize MPI */ int rc = MPI_Init(&argc, &argv); if(rc != MPI_SUCCESS){ printf ("Error starting MPI program. Terminating.\n"); MPI_Abort (MPI_COMM_WORLD, rc); } /* get MPI environment */ MPI_Comm_size (MPI_COMM_WORLD, &task_num); MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* check and load arguements */ if(argc != 9){ printf("arguements error\n"); exit(EXIT_FAILURE); } load_args(argv); x_enable = (rank == 0) ? x_enable : 0; // only rank 0 (master) use X window /* initialize X window */ if(x_enable){ init_X(); XFlush(X.display); } /* start mandelbrot set test for every pixel */ pixel_value = malloc_2d_int(point_num_x, point_num_y); node_time = (double*)malloc(task_num * sizeof(double)); double begin = MPI_Wtime(); if(rank == 0){ mpi_master(); } else{ mpi_slaver(); } double end = MPI_Wtime(); total_time = end - begin; if(rank == 0){ printf("(N,Total"); for(i=0; i<task_num; i++){ printf(",N%d", i+1); } printf(")->(%d,%lf", point_num_x*point_num_y, total_time); for(i=0; i<task_num; i++){ printf(",%lf", node_time[i]); } printf(")\n"); } free(node_time); free_2d_int(pixel_value, point_num_x); /* show result */ if(x_enable){ sleep(3); } MPI_Finalize(); }