Exemplo n.º 1
0
int run(int argc, char** argv)
{
  init(argc, argv);

  /* --------------- pyramid parameters --------------- */
  int borderCols = (pyramid_height)*HALO;
  int smallBlockCol = BLOCK_SIZE-(pyramid_height)*HALO*2;
  int blockCols = cols/smallBlockCol+((cols%smallBlockCol==0)?0:1);

  printf("pyramidHeight: %d\ngridSize: [%d]\nborder:[%d]\nblockSize: %d\nblockGrid:[%d]\ntargetBlock:[%d]\n",\
      pyramid_height, cols, borderCols, BLOCK_SIZE, blockCols, smallBlockCol);

  DATATYPE *gpuWall, *gpuResult[2];
  int size = rows*cols;

  gpuResult[0] = (DATATYPE*)malloc(sizeof(DATATYPE)*cols);
  gpuResult[1] = (DATATYPE*)malloc(sizeof(DATATYPE)*cols);
  memcpy(gpuResult[0], data, sizeof(DATATYPE)*cols);
  gpuWall = (DATATYPE*)malloc(sizeof(DATATYPE)*(size-cols));
  memcpy(gpuWall, data+cols, sizeof(DATATYPE)*(size-cols));
  int final_ret = calc_path(gpuWall, gpuResult, rows, cols, \
      pyramid_height, blockCols, borderCols);

  memcpy(result, gpuResult[final_ret], sizeof(DATATYPE)*cols);

#ifdef BENCH_PRINT
  for (int i = 0; i < cols; i++)
    printf("%d ",data[i]);
  printf("\n");
  for (int i = 0; i < cols; i++)
    printf("%d ",result[i]);
  printf("\n");
#endif
  int passed = test_output(result, rows, cols, "cuda/gold_output.txt");
  free(gpuWall);
  free(gpuResult[0]);
  free(gpuResult[1]);
  delete [] data;
  delete [] wall;
  delete [] result;

  if (passed) {
    printf("PASSED.\n");
    return 0;
  } else {
    printf("FAILED.\n");
    return 1;
  }
}
Exemplo n.º 2
0
/*
 * returns an error code if initialization fails
 */
int init_with_instance(HMODULE hmod, char *frozen)
{
	int rc;
	if (!_LocateScript(hmod))
		return 255;

	if (!_LoadPythonDLL(hmod))
		return 255;
	if (p_script_info->unbuffered) {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
		_setmode(fileno(stdin), O_BINARY);
		_setmode(fileno(stdout), O_BINARY);
#endif
#ifdef HAVE_SETVBUF
		setvbuf(stdin,	(char *)NULL, _IONBF, BUFSIZ);
		setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
		setvbuf(stderr, (char *)NULL, _IONBF, BUFSIZ);
#else /* !HAVE_SETVBUF */
		setbuf(stdin,  (char *)NULL);
		setbuf(stdout, (char *)NULL);
		setbuf(stderr, (char *)NULL);
#endif /* !HAVE_SETVBUF */
	}

	if (getenv("PY2EXE_VERBOSE"))
		Py_VerboseFlag = atoi(getenv("PY2EXE_VERBOSE"));
	else
		Py_VerboseFlag = 0;

	Py_IgnoreEnvironmentFlag = 1;
	Py_NoSiteFlag = 1;
	Py_OptimizeFlag = p_script_info->optimize;

	Py_SetProgramName(modulename);

	calc_path();

	if (!Py_IsInitialized()) {
		// First time round and the usual case - set sys.path
		// statically.
		rc = set_path_early();
		if (rc != 0)
			return rc;
	
	//	printf("Path before Py_Initialize(): %s\n", Py_GetPath());
	
		Py_Initialize();
	//	printf("Path after Py_Initialize(): %s\n", PyString_AsString(PyObject_Str(PySys_GetObject("path"))));
	} else {
		// Python already initialized.  This likely means there are
		// 2 py2exe based apps in the same process (eg, 2 COM objects
		// in a single host, 2 ISAPI filters in the same site, ...)
		// Until we get a better answer, add what we need to sys.path
		rc = set_path_late();
		if (rc != 0)
			return rc;
	}
	/* Set sys.frozen so apps that care can tell.
	   If the caller did pass NULL, sys.frozen will be set zo True.
	   If a string is passed this is used as the frozen attribute.
	   run.c passes "console_exe", run_w.c passes "windows_exe",
	   run_dll.c passes "dll"
	   This falls apart when you consider that in some cases, a single
	   process may end up with two py2exe generated apps - but still, we
	   reset frozen to the correct 'current' value for the newly
	   initializing app.
	*/
	if (frozen == NULL)
		PySys_SetObject("frozen", PyBool_FromLong(1));
	else {
		PyObject *o = PyString_FromString(frozen);
		if (o) {
			PySys_SetObject("frozen", o);
			Py_DECREF(o);
		}
	}

	_TryLoadZlib(hmod);

	return 0;
}