void omp_task_matmuld(double **a, double **b, double **c, int nthr) { /* this call is needed to set the number * of threads */ omp_set_num_threads(nthr); #pragma omp parallel { #pragma omp single { for(int i=0;i<1024;i++) { /* CS194: add pragmas to this loop-nest * to enable OpenMP task parallelism */ #pragma omp task { do_mv(a,b,c,i); } } } } }
int main( int ac, char * av[] ) { if( ac != 3 ) { fprintf(stderr, "usage : %s source destination\n", *av); exit(1); } return do_mv( av[1], av[2] ); }
int main(int argc, char *argv[]) { char *ptr; if (NULL != (ptr = strrchr(argv[0], '/'))) ptr++; else ptr = argv[0]; if (strcmp(ptr, "e2tools") == 0) { if (argc < 2) { usage(); exit(1); } ++argv; --argc; ptr = argv[0]; } initialize_ext2_error_table(); if (strcmp(ptr, "e2ls") == 0) exit(do_list_dir(argc, argv)); else if (strcmp(ptr, "e2cp") == 0) exit(copy(argc, argv)); else if (strcmp(ptr, "e2mkdir") == 0) exit(e2mkdir(argc, argv)); else if (strcmp(ptr, "e2ln") == 0) exit(do_ln(argc, argv)); else if (strcmp(ptr, "e2mv") == 0) exit(do_mv(argc, argv)); else if (strcmp(ptr, "e2rm") == 0) exit(e2rm(argc, argv)); else if (strcmp(ptr, "e2tail") == 0) exit(do_tail(argc, argv)); else { fprintf(stderr, "Not implemented\n"); exit(1); } return(0); }
int main (int argc, char **argv) { int exit = 0; char *buffer = g_new (char, 1024) ; GIOChannel *ioc; guint watch_id = 0; GOptionContext *ctx = NULL; GError *error = NULL; /* default to interactive on a terminal */ interactive = isatty (0); ctx = g_option_context_new("test-vfs"); g_option_context_add_main_entries(ctx, options, NULL); if (!g_option_context_parse(ctx, &argc, &argv, &error)) { g_printerr("main: %s\n", error->message); g_error_free(error); g_option_context_free(ctx); return 1; } g_option_context_free(ctx); files = g_hash_table_new (g_str_hash, g_str_equal); if (noninteractive) interactive = FALSE; if (interactive) vfserr = stderr; else vfserr = stdout; if (!mate_vfs_init ()) { fprintf (vfserr, "Cannot initialize mate-vfs.\n"); return 1; } mate_vfs_module_callback_push (MATE_VFS_MODULE_CALLBACK_AUTHENTICATION, authentication_callback, NULL, NULL); if (argc == 1) cur_dir = g_get_current_dir (); else cur_dir = g_strdup(argv[1]); if (cur_dir && !G_IS_DIR_SEPARATOR (cur_dir [strlen (cur_dir) - 1])) cur_dir = g_strconcat (cur_dir, G_DIR_SEPARATOR_S, NULL); if (interactive == TRUE) { main_loop = g_main_loop_new (NULL, TRUE); ioc = g_io_channel_unix_new (0 /* stdin */); g_io_channel_set_encoding (ioc, NULL, NULL); g_io_channel_set_buffered (ioc, FALSE); watch_id = g_io_add_watch (ioc, G_IO_IN | G_IO_HUP | G_IO_ERR, callback, buffer); g_io_channel_unref (ioc); } while (!exit) { char *ptr; if (interactive) { fprintf (stdout,"\n%s > ", cur_dir); fflush (stdout); strcpy (buffer, ""); g_main_loop_run (main_loop); } else { /* In non-interactive mode we just do this evil * thingie */ buffer[0] = '\0'; fgets (buffer, 1023, stdin); if (!buffer [0]) { exit = 1; continue; } } if (!buffer || buffer [0] == '#') continue; arg_data = g_strsplit (g_strchomp (buffer), delim, -1); arg_cur = 0; if ((!arg_data || !arg_data[0]) && interactive) continue; if (!interactive) printf ("Command : '%s'\n", arg_data [0]); ptr = arg_data[arg_cur++]; if (!ptr) continue; if (g_ascii_strcasecmp (ptr, "ls") == 0) do_ls (); else if (g_ascii_strcasecmp (ptr, "cd") == 0) do_cd (); else if (g_ascii_strcasecmp (ptr, "dump") == 0) do_dump (); else if (g_ascii_strcasecmp (ptr, "type") == 0 || g_ascii_strcasecmp (ptr, "cat") == 0) do_cat (); else if (g_ascii_strcasecmp (ptr, "cp") == 0) do_cp (); else if (g_ascii_strcasecmp (ptr, "rm") == 0) do_rm (); else if (g_ascii_strcasecmp (ptr, "mkdir") == 0) do_mkdir (); else if (g_ascii_strcasecmp (ptr, "rmdir") == 0) do_rmdir (); else if (g_ascii_strcasecmp (ptr, "mv") == 0) do_mv (); else if (g_ascii_strcasecmp (ptr, "info") == 0 || g_ascii_strcasecmp (ptr, "stat") == 0) do_info (); else if (g_ascii_strcasecmp (ptr, "findtrash") == 0) do_findtrash (); else if (g_ascii_strcasecmp (ptr, "ssl") == 0) do_ssl (); else if (g_ascii_strcasecmp (ptr, "sync") == 0) fprintf (vfserr, "a shell is like a boat, it lists or syncs (RMS)\n"); else if (g_ascii_strcasecmp (ptr,"help") == 0 || g_ascii_strcasecmp (ptr,"?") == 0 || g_ascii_strcasecmp (ptr,"info") == 0 || g_ascii_strcasecmp (ptr,"man") == 0) list_commands (); else if (g_ascii_strcasecmp (ptr,"exit") == 0 || g_ascii_strcasecmp (ptr,"quit") == 0 || g_ascii_strcasecmp (ptr,"q") == 0 || g_ascii_strcasecmp (ptr,"bye") == 0) exit = 1; /* File ops */ else if (g_ascii_strcasecmp (ptr, "open") == 0) do_open (); else if (g_ascii_strcasecmp (ptr, "create") == 0) do_create (); else if (g_ascii_strcasecmp (ptr, "close") == 0) do_close (); else if (g_ascii_strcasecmp (ptr, "handleinfo") == 0) do_handleinfo (); else if (g_ascii_strcasecmp (ptr, "read") == 0) do_read (); else if (g_ascii_strcasecmp (ptr, "seek") == 0) do_seek (); else fprintf (vfserr, "Unknown command '%s'", ptr); g_strfreev (arg_data); arg_data = NULL; } if (interactive) { g_source_remove (watch_id); g_main_loop_unref (main_loop); main_loop = NULL; } g_free (buffer); g_free (cur_dir); close_files (); return 0; }