/*! substrcts a region from another. */ BOOL gdi_subtract_cliprgn(cliprgn_t *p_difference_rgn, const cliprgn_t *p_minuend_rgn, const cliprgn_t *p_subtrahend_rgn) { // checks all the simple cases if((!(p_minuend_rgn->p_head)) || (!(p_subtrahend_rgn->p_head)) || (!is_rect_intersected( &p_minuend_rgn->bound, &p_subtrahend_rgn->bound))) { gdi_copy_cliprgn(p_difference_rgn, p_minuend_rgn); return TRUE; } cliprgn_set_op(p_difference_rgn, p_minuend_rgn, p_subtrahend_rgn, do_overlap_subtract, do_non_overlap_subtract, NULL); /*! Can't alter newReg's bound before we call miRegionOp because it might be one of the source regions and miRegionOp depends on the bound of those regions being the unaltered. Besides, this way there's no checking against rectangles that will be nuked due to coalescing, so we have to examine fewer rectangles. */ calc_bound(p_difference_rgn); return TRUE; }
/*! unions two regions. */ BOOL gdi_union_cliprgn(cliprgn_t *p_dst_rgn, const cliprgn_t *p_src_rgn1, const cliprgn_t *p_src_rgn2) { // checks all the simple cases // region 1 and 2 are the same or region 1 is empty if((p_src_rgn1 == p_src_rgn2) || (!(p_src_rgn1->p_head))) { if(p_dst_rgn != p_src_rgn2) { gdi_copy_cliprgn(p_dst_rgn, p_src_rgn2); } return TRUE; } // if nothing to union (region 2 empty) if(NULL == (p_src_rgn2->p_head)) { if(p_dst_rgn != p_src_rgn1) { gdi_copy_cliprgn(p_dst_rgn, p_src_rgn1); } return TRUE; } // region 1 completely subsumes region 2 if((p_src_rgn1->p_head == p_src_rgn1->p_tail) && (p_src_rgn1->bound.left <= p_src_rgn2->bound.left) && (p_src_rgn1->bound.top <= p_src_rgn2->bound.top) && (p_src_rgn1->bound.right >= p_src_rgn2->bound.right) && (p_src_rgn1->bound.bottom >= p_src_rgn2->bound.bottom)) { if(p_dst_rgn != p_src_rgn1) { gdi_copy_cliprgn(p_dst_rgn, p_src_rgn1); } return TRUE; } // region 2 completely subsumes region 1 if((p_src_rgn2->p_head == p_src_rgn2->p_tail) && (p_src_rgn2->bound.left <= p_src_rgn1->bound.left) && (p_src_rgn2->bound.top <= p_src_rgn1->bound.top) && (p_src_rgn2->bound.right >= p_src_rgn1->bound.right) && (p_src_rgn2->bound.bottom >= p_src_rgn1->bound.bottom)) { if(p_dst_rgn != p_src_rgn2) { gdi_copy_cliprgn(p_dst_rgn, p_src_rgn2); } return TRUE; } // normal cliprgn_set_op(p_dst_rgn, p_src_rgn1, p_src_rgn2, do_overlap_union, do_non_overlap_union, do_non_overlap_union); calc_bound(p_dst_rgn); return TRUE; }
/*! intersects two region. */ BOOL gdi_intersect_cliprgn(cliprgn_t *p_dst_rgn, const cliprgn_t *p_src_rgn1, const cliprgn_t *p_src_rgn2) { /*! check */ if((!(p_src_rgn1->p_head)) || (!(p_src_rgn2->p_head)) || (!is_rect_intersected(&p_src_rgn1->bound, &p_src_rgn2->bound))) { gdi_empty_cliprgn(p_dst_rgn); return FALSE; } else { cliprgn_set_op(p_dst_rgn, p_src_rgn1, p_src_rgn2, do_overlap_intersect, NULL, NULL); } /*! Can't alter dst_rgn's bound before we call miRegionOp because it might be one of the source regions and miRegionOp depends on the bound of those regions being the same. Besides, this way there's no checking against rectangles that will be nuked due to coalescing, so we have to examine fewer rectangles. */ calc_bound(p_dst_rgn); return TRUE; }
int algo() { int i, j; int RWmP[MAX_TASK_NUM]; fscanf(fin, "%d%d%d%d", &true_task_num, &task_num, &processor_num, &lcm_period); period=(int *)malloc(sizeof(int)*task_num); execute=(int *)malloc(sizeof(int)*task_num); w=(float *)malloc(sizeof(float)*task_num); for(i=0; i<task_num; i++) fscanf(fin, "%d", &period[i]); for(i=0; i<task_num; i++) fscanf(fin, "%d", &execute[i]); for(i=0; i<task_num; i++) { w[i]=((float)execute[i])/((float)period[i]); RWmP[i]=0; } calc_bound(); initialize(); calc_alpha(); calc_UF(); for(i=0; i<processor_num; i++) for(j=0; j<lcm_period; j++) alloc[i][j]=-1; for(i=0; i<row_num; i++) Bfair(RWmP, i); /* for(i=0; i<processor_num; i++) { for(j=0; j<lcm_period; j++) { fprintf(fout, "%d ", alloc[i][j]); } fprintf(fout, "\n"); }*/ if(checkSchedule()==-1) { printf("!!!Schedule error.\n"); } else printf("successfully scheduling.\n"); countPreemption(); countMigration(); countEvent(); fprintf(flog, "preemption:\n"); for(i=0; i<true_task_num; i++) { double ppj=((double)preemption[i])/((double)(lcm_period/period[i])); fprintf(flog, "%lf ", ppj); } fprintf(flog, "\n"); fprintf(flog, "migration:\n"); for(i=0; i<true_task_num; i++) { double mpj=((double)migration[i])/((double)(lcm_period/period[i])); fprintf(flog, "%lf ", mpj); } fprintf(flog, "\n"); fprintf(flog, "event:\n"); for(i=0; i<true_task_num; i++) { double epj=((double)event[i])/((double)(lcm_period/period[i])); fprintf(flog, "%lf ", epj); } fprintf(flog, "\n"); remains(); return 0; }
main() #endif { FILE *fp = stdin; /* File pointer, default stdin */ CRITICALS *tuples, *lower_dim_tuples; int i, temp; BOUNDARY **boundary; CUBE *cube; int n, num_rows, num_cols; MATRIX matrix, tmatrix; printf("\ncmat - version %1.2f\n\n", VERSION_NUM); #ifndef NO_CMD_LINE /* Check the command line and open file if required */ command_line(&fp,argc, argv, &n); #else /* Read command info from standard input */ command_input(&fp, &n); #endif /* Read in info from the file, setting up Fsa and so on... */ switch (read_file_info(fp)) { case FORMAT_ERROR: ERROR(FORMAT); case NOT_A_GEN: ERROR(GEN_ERR); } fclose(fp); /* No more reading required */ tuples = find_n_criticals(n); /* remove_inverse_criticals(&tuples); We are ignoring inverse tuples */ /* Calc boundaries and store in an array */ boundary = NEW(BOUNDARY *, tuples->num); for (i = 0; i < tuples->num; i++) { boundary[i] = calc_bound(cube = create_n_cube(tuples->info[i]->word, tuples->info[i]->vert, n), TRIVIAL | RETAIN_INV_TUPLES); /* We are ignoring inverse tuples */ delete_cube(cube); } lower_dim_tuples = find_n_criticals(n-1); /* remove_inverse_criticals(&lower_dim_tuples); Ignoring inverse tuples */ num_rows = tuples->num; /* Create the matrix */ matrix = make_matrix_n(boundary, lower_dim_tuples, &num_rows); num_cols = lower_dim_tuples->num; /* It is often useful to have rows and columns the other way */ /* Get transpose, and swap rows and cols */ tmatrix = transpose(matrix, num_cols, num_rows); temp = num_rows; num_rows = num_cols; num_cols = temp; /* Display....for now */ printf("\nMatrix: rows = %d, cols = %d\n\n", num_rows, num_cols); show_matrix(stdout, tmatrix, num_cols, num_rows, 20); /*printf("\nMatrix after Gaussian Elimination...\n"); gaussian_elim(matrix, num_cols, num_rows); show_matrix(stdout, matrix, num_cols, num_rows); rank_criticals_n = count_non_zero_rows(matrix, num_cols, num_rows);*/ /* Clean up */ for (i=0; i < tuples->num - Num_gens; i++) delete_boundary(boundary[i]); free(boundary); delete_criticals(tuples); delete_criticals(lower_dim_tuples); delete_matrix(matrix, num_cols); delete_matrix(tmatrix, num_rows); return 0; }