예제 #1
0
파일: chol_3.c 프로젝트: jwegrzy/OORA
int
main(int argc, char** argv)
{
	double *A;
	int n, ret, event;
	double startTime;
	double endTime;
	long long value;

	n = atoi(argv[2]);
	A = load_matrix(argv[1], n);
	event = atoi(argv[3]);
	if (event != 5) {
  		papi_init(event);
	  	papi_start();
	} else {
		startTime = dclock();
	}
	ret = chol(A, n);
	if (event != 5) {
		value = papi_stop();
		printf("%lld\n", value);
	} else {
		endTime = dclock();
		printf("%lf\n", endTime - startTime);
	}
	fprintf(stderr, "RET:%d\n", ret);
	check(A,n);
	free(A);
	return 0;
}
예제 #2
0
파일: mm8.c 프로젝트: gronostajo/oora_lab5
int main(int argc, const char *argv[]) {
    int i, j, iret;
    double first[SIZE][SIZE];
    double second[SIZE][SIZE];
    double multiply[SIZE][SIZE];
    double dtime;
    for (i = 0; i < SIZE; i++) {     // rows in first
        for (j = 0; j < SIZE; j++) { // columns in first
            first[i][j] = i + j;
            second[j][i] = i - j;
            multiply[i][j] = 0.0;
        }
    }
    papi_init(atoi(argv[1]));
    papi_start();
    iret = mm(first, second, multiply);
    papi_stop();

    double check = 0.0;
    for (i = 0; i < SIZE; i++) {
        for (j = 0; j < SIZE; j++) {
            check += multiply[i][j];
        }
    }
    fprintf(stderr, "check %le \n", check);

    return iret;
}
예제 #3
0
파일: mm1.c 프로젝트: ZawilecxD/OORA5
int main( int argc, const char* argv[] )
{

	papi_init();
	int i,j,iret,w;
	for(w = 320;w<640;w+=64){
		SIZE = w;
		double first[SIZE][SIZE];
		double second[SIZE][SIZE];
		double multiply[SIZE][SIZE];
		double dtime;
		for (i = 0; i < SIZE; i++) { //rows in first
			for (j = 0; j < SIZE; j++) { //columns in first
				first[i][j]=i+j;
				second[i][j]=i-j;
				multiply[i][j]=0.0;
			}
		}
		papi_start();
		iret=mm(first,second,multiply); 
		papi_stop((w-320)/64);
	}
	print_papi_results();
	return iret;
}
예제 #4
0
int main(int argc, char *argv[]) {
  unsigned n;
  int evt;
  double *A;
  int i, j;
  double checksum = 0;
  double startTime, endTime;
  long long counter;

  if (argc < 2) {
    return -1;
  }

  n = atoi(argv[1]);
  evt = (argc > 2) ? atoi(argv[2]) : -1;

  A = randomMatrix(n);
  assert(A != NULL);

  if (evt == -1) {
    startTime = dclock();
  } else {
    papi_init(evt);
    papi_start();
  }

  if (chol(A, n)) {
    fprintf(stderr, "Error: matrix is either not symmetric or not positive definite.\n");
  } else {
    for (i = 0; i < n; i++) {
        for (j = i; j < n; j++) {
            checksum += A[IDX(i, j, n)];
        }
    }
    printf("Checksum: %f \n", checksum);
  }

  if (evt == -1) {
    endTime = dclock();
    fprintf(stderr, "%f\n", endTime - startTime);

  } else {
    counter = papi_stop();
    fprintf(stderr, "%lld\n", counter);
  }

  free(A);
  return 0;
}
예제 #5
0
파일: mm8.c 프로젝트: sodzawic/oora
int main( int argc, const char* argv[] )
{
  int i,j,iret;
  if (argc > 1) {
    double first[SIZE][SIZE];
    double second[SIZE][SIZE];
    double multiply[SIZE][SIZE];
    double dtime;
    for (i = 0; i < SIZE; i++) { //rows in first
      for (j = 0; j < SIZE; j++) { //columns in first
        first[i][j]=i+j;
        second[i][j]=i-j;
        multiply[i][j]=0.0;
      }
    }
    struct papi_context context = papi_start(argv[1]);
    dtime = dclock();
    iret=mm(first,second,multiply); 
    dtime = dclock()-dtime;
    papi_stop(context);
    printf( "Time: %le \n", dtime);

    double check=0.0;
    for(i=0;i<SIZE;i++){
      for(j=0;j<SIZE;j++){
        check+=multiply[i][j];
      }
    }
    printf("check %le \n",check); 
    fflush( stdout );
  } else {
    printf ("%s <event_name>\n", argv[0]);
  }

  return iret;
}
예제 #6
0
파일: icecapvm.c 프로젝트: Gudui/hvm-scj
int run_vm(void) {
#if !defined(VM_CLOCKINTERRUPTHANDLER_INTERRUPT)
	Object temp;
	int32* mainMethodJavaStack;
#endif

	int16 execp = 0;
	/* Required for certain compilers. */
	init_compiler_specifics();

	/* Function below allocates the initial heap. This is done in
	 * initDefaultRAMAllocationPoint in allocation_point.c
	 */
	init_vm();

#if defined(ENABLE_DEBUG)
	connectToDebugger();
	sendStartEvent();
	while (awaitCommandFromDebugger(0, 0, 0) != RESUME_EVENT) {;}
#endif

	/* Allocating the main stack is delegated to the target specific function
	 * 'get_java_stack_base'. On some architectures/environments it is located
	 * at fixed positions in certain compiler specific sections. The implementor
	 * can allocate the stack in the heap if so desired.
	 * */
	mainMethodJavaStack = get_java_stack_base(JAVA_STACK_SIZE);

#if defined(VM_CLOCKINTERRUPTHANDLER_INTERRUPT)
	/* If more threads are started we give the main thread a new C stack pointer.
	 * In case of no other threads running the main thread just inherits the
	 * current C stack.
	 *
	 * In this case we save the current C stack so we may restore it later. This
	 * is required to terminate the process properly.
	 */
	mainStackPointer = (pointer) get_stack_pointer();

	/* mainMethodJavaStack contains both Java and C stack. Java stack grows
	 * upwards from the beginning, C stack downwards from the end. */
	stackPointer = (pointer) &mainMethodJavaStack[JAVA_STACK_SIZE - 2];
	/* 'set_stack_pointer' sets the C stack */
	stackPointer = (pointer) & mainMethodJavaStack[JAVA_STACK_SIZE - 2];
	set_stack_pointer();
#endif

#if defined(REPORTCYCLES)
	papi_start();
	papi_mark();
	papi_mark();
	papi_mark();
	papi_mark();
	papi_mark();
	papi_mark();
#endif

#if defined(LDC2_W_OPCODE_USED) || defined(LDC_W_OPCODE_USED) || defined(LDC_OPCODE_USED) || defined(HANDLELDCWITHINDEX_USED)
	execp = initializeConstants(mainMethodJavaStack);
	if (execp == -1) {
#endif

		execp = initializeExceptions(mainMethodJavaStack);
		if (execp == -1) {

#if defined(INVOKECLASSINITIALIZERS)
			execp = invokeClassInitializers(mainMethodJavaStack);
			if (execp == -1) {
#endif
				/* This is only for testing. All tests will write 0 (null) to
				 * '*mainMethodJavaStack' if the test is successful.
				 */
				*mainMethodJavaStack = (int32) (pointer) &temp;

#if defined(VM_CLOCKINTERRUPTHANDLER_ENABLE_USED)
				start_system_tick();
#endif

#if defined(DEVICES_SYSTEM_INITIALIZESYSTEMCLASS)
				execp = enterMethodInterpreter(
				DEVICES_SYSTEM_INITIALIZESYSTEMCLASS, mainMethodJavaStack);
				if (execp == -1) {
#endif
						/* Start the VM */
						execp = enterMethodInterpreter(mainMethodIndex,
								mainMethodJavaStack);
#if defined(VM_CLOCKINTERRUPTHANDLER_ENABLE_USED)
						stop_system_tick();
#endif
#if defined(DEVICES_SYSTEM_INITIALIZESYSTEMCLASS)
				}
#endif
			}
			/* TODO: use executeWithStack instead */
#if defined(INVOKECLASSINITIALIZERS)
		}
#endif

#if defined(LDC2_W_OPCODE_USED) || defined(LDC_W_OPCODE_USED) || defined(LDC_OPCODE_USED) || defined(HANDLELDCWITHINDEX_USED)
	}
#endif

#if defined(REPORTCYCLES)
	papi_mark();
#endif

	mark_error();

	if (execp >= 0) {
#if defined(JAVA_LANG_THROWABLE_INIT_)
		handleException(execp);
#endif
#if defined(VM_CLOCKINTERRUPTHANDLER_INTERRUPT)
		/* Restore C stack pointer. Otherwise we could not return from here properly */
		stackPointer = (pointer) mainStackPointer;
		set_stack_pointer();
#endif
		return ERROR;
	}

#if defined(VM_CLOCKINTERRUPTHANDLER_INTERRUPT)
	/* Restore C stack pointer. Otherwise we could not return from here properly */
	stackPointer = (pointer) mainStackPointer;
	set_stack_pointer();
#endif

#if defined(ENABLE_DEBUG)
	disconnectFromDebugger();
#endif

	if (*mainMethodJavaStack) {
		return ERROR;
	} else {
		mark_success();
		return SUCCESS;
	}

	return 0;
}
int main(int argc, char **argv) {
	//int dims[3] = {5,10,15};
	//int dim = 4;
	//int block_dim = 2;
  double time,avg;
  MPI_Init(&argc, &argv);
	int procs;
	int rank;
	MPI_Comm_size(MPI_COMM_WORLD, &procs);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);

#if doPAPI==1
	data = 0;
	papi_setup();
#endif

	//Check if number of processes is a perfect square
	if (sqrt(procs) != floor(sqrt(procs))) {
		printf("Number of processes is not a perfect square!\n");
		return -1;
	}

	//Read input arguements
	if(argc < 2) {
		if(rank == 0)
			fprintf(stderr,"Wrong # of arguments.\nUsage: mpirun -n procs %s $dim $numThreads $rank2print $doSerial(Only dim and numThreads are required; other 2 are optional)\n",argv[0]);
		return -1;
	}
	int dim = atoi(argv[1]);
  int numThreads = atoi(argv[2]);
	int block_dim = dim/(sqrt(procs));
	int rank2print = -1;
	int doSerial = 0;
	if(argc == 4) {
		rank2print = atoi(argv[3]);
	}
	if(argc == 5) {
		rank2print = atoi(argv[3]); 
		doSerial = atoi(argv[4]);
	}

	//Run code
	if(rank==0)
		printf("Running code on %i procs with dim = %i; numThreads = %i; block_dim = %i; printing on rank %i; doSerial = %i \n",procs, dim, numThreads, block_dim, rank2print, doSerial);
	if(doSerial==1) 
		serial_lu(generate_matrix(dim),dim);
#if doPAPI==1
	papi_start();
	parallel_lu(argc, argv, generate_matrix(dim), dim, block_dim, rank2print, doSerial, numThreads);
	papi_report();
#else
  time = MPI_Wtime();
  parallel_lu(argc, argv, generate_matrix(dim), dim, block_dim, rank2print, doSerial, numThreads);
  time = MPI_Wtime() - time;
  MPI_Reduce(&time, &avg, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
  if(rank == 0) {
    printf("Dim = %i, Procs = %i, Threads = %i, Average time: %e\n", dim, procs, numThreads, avg/procs);
  }
#endif
  MPI_Finalize();
	return 0;
}