Beispiel #1
0
int main(int argc, char** argv)
{

    int grid_size_x;
    int grid_size_y;
    int max_iter;
    float xmin;
    float xmax;
    float ymin;
    float ymax;
    int **image;
    int rank;
//initialise a fn pointer
    in_set_fn_t fp; 
    MPI_Comm comm;
    comm = MPI_COMM_WORLD;

    MPI_Init(&argc, & argv);

    MPI_Comm_rank(comm, &rank); 

    read_options(argc, argv, &grid_size_x, &grid_size_y, &max_iter,
                 &xmin, &xmax, &ymin, &ymax);

    if(0 == rank)
    {
      initialise_image(&image, grid_size_x, grid_size_y);
    }


//set it to either julia or mandelbrot calculation
    fp = &point_in_julia;  

    compute_set(fp, image, xmin, xmax, ymin, ymax, grid_size_x, grid_size_y, max_iter, comm);

    if(0 == rank)
    {
      write_ppm("output.ppm", image, grid_size_x, grid_size_y, max_iter);
      free(image);
    }

    MPI_Finalize();
    return 0;
}
Beispiel #2
0
int
main(int argc, char **argv, char **envp)
{
	int	i;

	scale_init(argc, argv);

#define ALIGNMENTOFFSET 2 /* adjust alignment */
        i = sizeof(workStruct_t)*
            (narrays+ALIGNMENTOFFSET);
        element = memalign(64, i);
	if ( element == NULL ) {
	    perror("calloc( narrays, sizeof(workStruct_t) )");
	    exit(1);
	}
        compute_set(element);
        memset(element, 0, i);
        element+=ALIGNMENTOFFSET;

#ifdef SELFTEST
	start_prof();
#endif

	fid = open_output("mttest.acct");
	if (job_index == -1) {
		i = (sizeof(scripttab)/sizeof( struct scripttab) -1 );
	} else {
		i = 1;
	}
	fprintf(fid, "Number of tests: %d  Repeat count: %d\n",
		i, repeat_count);

	fprintf(fid, "MHz: %d\n", get_clock_rate() );

	fprintf(fid,
	    "X    Incl. Total   Incl. CPU   Incl. Sync. Wait   Name (%s)\n",
		model);
	fflush(fid);
  
	name = strdup(argv[0]);

	init_micro_acct();
#if OS(Solaris) 
	if(uniprocessor != 0) {
	    /* call processor_bind to force single CPU */
	    processor_bind(P_PID, P_MYID, cpuid, NULL);
	}
#endif /* OS(Solaris) */

#ifdef SOLARIS
	sema_init(&global_sema_lock, count, USYNC_THREAD, NULL);
#endif
#ifdef POSIX
	pthread_attr_init(&attr);

    #ifdef BOUND
	pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
    #endif

	sem_init(&global_sema_lock, 0, count);
#endif

#if 0
	if ((s5_sema_id = semget(IPC_PRIVATE, 1, 0600)) == -1)
		perror("semget: IPC_PRIVATE");

	arg.val = count;
	if (semctl(s5_sema_id, 0, SETVAL, arg) == -1)
		perror("semctl: SETVAL");
#endif

	resolve_symbols();

	i = locktest();
#if 0
	if (semctl(s5_sema_id, 0, IPC_RMID) == -1)
		perror("semctl: IPC_RMID");
#endif

	close_file(fid);

#ifdef SELFTEST
        finish_prof();
#endif

	return 0;
}