int main(int argc, char * argv[]) {
    mtype_t * matrix = NULL ;
    int i, MAX_SIZE;
    double avg_time;
    support_init();
    
    MAX_ITERS = 100;
    
    if(argc==2)
        if(atoi(argv[1])>=2)
            MAX_SIZE = atoi(argv[1]);
        else{
        printf("The argument must be an integer and larger than or equal to 2");
        return -1;
        }
    else if(argc>2){
        printf("This program takes one or no arguments, you entered too many.");
        return -1;
    }
    else MAX_SIZE = 1024;
    for ( i = 2; i <= MAX_SIZE; i = i * 2 ) {
        // Allocate a matrix of size : buffer_side x buffer_side
        allocate_matrix (& matrix , i );
        // Clear / Initialize the matrix
        clear_matrix (matrix , i );
        
        avg_time = run_experiment_ij (matrix, 5.0, i);
        printf("The average time to do scalar multiplication ij on a %d x %d matrix is %lf \n", i, i, avg_time);
    }
    printf("------------------------------------------------------------------------------\n");
    for ( i = 2; i <= MAX_SIZE; i = i * 2 ) {
        // Allocate a matrix of size : buffer_side x buffer_side
        allocate_matrix (& matrix , i );
        // Clear / Initialize the matrix
        clear_matrix (matrix , i );
        
        avg_time = run_experiment_ji (matrix, 5.0, i);
        printf("The average time to do scalar multiplication ji on a %d x %d matrix is %lf \n", i, i, avg_time);
    }

    support_finalize();
    
    return 0;
}
int
main (int argc, char **argv)
{
  AppearanceData *data;
  GtkWidget *w;

  gchar *install_filename = NULL;
  gchar *start_page = NULL;
  gchar **wallpaper_files = NULL;
  GOptionContext *option_context;
  GOptionEntry option_entries[] = {
      { "install-theme",
        'i',
        G_OPTION_FLAG_IN_MAIN,
        G_OPTION_ARG_FILENAME,
        &install_filename,
        N_("Specify the filename of a theme to install"),
        N_("filename") },
      { "show-page",
        'p',
        G_OPTION_FLAG_IN_MAIN,
        G_OPTION_ARG_STRING,
        &start_page,
        /* TRANSLATORS: don't translate the terms in brackets */
        N_("Specify the name of the page to show (theme|background|fonts|interface)"),
        N_("page") },
      { G_OPTION_REMAINING,
      	0,
      	G_OPTION_FLAG_IN_MAIN,
      	G_OPTION_ARG_FILENAME_ARRAY,
      	&wallpaper_files,
      	NULL,
      	N_("[WALLPAPER...]") },
      { NULL }
    };

  option_context = g_option_context_new (NULL);
  g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE);

  /* init */
  data = init_appearance_data (&argc, &argv, option_context);
  if (!data)
    return 1;

  /* init tabs */
  themes_init (data);
  style_init (data);
  desktop_init (data, (const gchar **) wallpaper_files);
  g_strfreev (wallpaper_files);
  font_init (data);

  /* init support for other window managers */
  support_init (data);

  /* prepare the main window */
  w = appearance_capplet_get_widget (data, "appearance_window");
  capplet_set_icon (w, "preferences-desktop-theme");
  gtk_widget_show_all (w);

  g_signal_connect_after (w, "response",
                          (GCallback) main_window_response, data);

  /* default to background page if files were given on the command line */
  if (wallpaper_files && !install_filename && !start_page)
    start_page = g_strdup ("background");

  if (start_page != NULL) {
    gchar *page_name;

    page_name = g_strconcat (start_page, "_vbox", NULL);
    g_free (start_page);

    w = appearance_capplet_get_widget (data, page_name);
    if (w != NULL) {
      GtkNotebook *nb;
      gint pindex;

      nb = GTK_NOTEBOOK (appearance_capplet_get_widget (data, "main_notebook"));
      pindex = gtk_notebook_page_num (nb, w);
      if (pindex != -1)
        gtk_notebook_set_current_page (nb, pindex);
    }
    g_free (page_name);
  }

  if (install_filename != NULL) {
    GFile *inst = g_file_new_for_commandline_arg (install_filename);
    g_free (install_filename);
    mate_theme_install (inst, GTK_WINDOW (w));
    g_object_unref (inst);
  }

  g_option_context_free (option_context);

  /* start the mainloop */
  gtk_main ();
  gdk_threads_leave ();

  /* free stuff */
  g_free (data);

  return 0;
}
Example #3
0
int main(int argc, char * argv[]) {    
    int N;
    int max_N = 1024;
    double time;
    mtype_t *matrix = NULL;
    mtype_t scalar = 1;
    
    // Initialize the support library
    support_init();
    
    /* Command line argument handling */
    if(argc >= 2) {
        if(is_valid_int(argv[1]) == 0){
            max_N = (int)strtol(argv[1], NULL, 10);
        }
    }
    
    /* run_experiment_ij */
    printf("\n---------------------------\n\n");
    printf("Executing: run_experiment_ij()\n\n");
    for(N = 2; N <= max_N;){
        allocate_matrix(&matrix, N);
        time = run_experiment_ij(matrix, scalar, N);
        printf("Matrix Size in bytes: %lu\n", sizeof(mtype_t) * N * N);
        printf("megaFLOPS = %f\n\n", (1 * N * N) / time / 1000000);
        N = N*2;
        
        /* Cleanup */
        if(matrix != NULL){
            free(matrix);
            matrix = NULL;
        }
    }
    
    /* run_experiment_ji */
    printf("\n---------------------------\n\n");
    printf("Executing: run_experiment_ji()\n\n");
    for(N = 2; N <= max_N;){
        allocate_matrix(&matrix, N);
        time = run_experiment_ji(matrix, scalar, N);
        printf("Matrix Size in bytes: %lu\n", sizeof(mtype_t) * N * N);
        printf("megaFLOPS = %f\n\n", (1 * N * N) / time / 1000000);
        N = N*2;
        
        /* Cleanup */
        if(matrix != NULL){
            free(matrix);
            matrix = NULL;
        }
    }
    
    /* Cleanup */
    if(matrix != NULL){
        free(matrix);
        matrix = NULL;
    }

    // Finalize the support library
    support_finalize();
    
    return 0;
}