Ejemplo n.º 1
0
int room_goto_previous()
{
    enigma::roomstruct *rit = enigma::roomdata[(int)room.rval.d];
    errcheck((int)room.rval.d,"Going to next room from invalid room. wat");

    rit = enigma::roomorder[rit->order - 1];
    errcheck(rit->order-1,"Going to next room after last");

    rit->gotome();
    return 0;
}
Ejemplo n.º 2
0
int room_goto_previous()
{
    enigma::roomstruct *rit = enigma::roomdata[(int)room.rval.d];
    errcheck((int)room.rval.d,"Going to next room from invalid room. wat", 0);

    rit = enigma::roomorder[rit->order - 1];
    errcheck(rit->order-1,"Going to next room after last", 0);

    enigma::room_switching_id = rit->id;
    enigma::room_switching_restartgame = false;
    return 1;
}
Ejemplo n.º 3
0
Object cuda_over_map(Object self, int nparts, int *argcv,
        Object *argv, int flags) {
    CUresult error;
    cuInit(0);
    int deviceCount = 0;
    error = cuDeviceGetCount(&deviceCount);
    if (deviceCount == 0) {
        raiseError("No CUDA devices found");
    }
    CUdevice cuDevice;
    CUcontext cuContext;
    CUmodule cuModule;
    CUfunction cuFunc;
    error = cuDeviceGet(&cuDevice, 0);
    error = cuCtxCreate(&cuContext, 0, cuDevice);
    CUdeviceptr d_A;
    CUdeviceptr d_B;
    CUdeviceptr d_res;
    errcheck(cuModuleLoad(&cuModule, grcstring(argv[argcv[0]])));
    CUdeviceptr dps[argcv[0]];
    void *args[argcv[0]+2];
    int size = INT_MAX;
    for (int i=0; i<argcv[0]; i++) {
        struct CudaFloatArray *a = (struct CudaFloatArray *)argv[i];
        if (a->size < size)
            size = a->size;
        errcheck(cuMemAlloc(&dps[i], size * sizeof(float)));
        errcheck(cuMemcpyHtoD(dps[i], &a->data, size * sizeof(float)));
        args[i+1] = &dps[i];
    }
    struct CudaFloatArray *r =
        (struct CudaFloatArray *)(alloc_CudaFloatArray(size));
    int fsize = sizeof(float) * size;
    errcheck(cuMemAlloc(&d_res, fsize));
    errcheck(cuMemcpyHtoD(d_res, &r->data, fsize));
    args[0] = &d_res;
    args[argcv[0]+1] = &size;

    int threadsPerBlock = 256;
    int blocksPerGrid = (size + threadsPerBlock - 1) / threadsPerBlock;
    char name[256];
    strcpy(name, "block");
    strcat(name, grcstring(argv[argcv[0]]) + strlen("_cuda/"));
    for (int i=0; name[i] != 0; i++)
        if (name[i] == '.') {
            name[i] = 0;
            break;
        }
    errcheck(cuModuleGetFunction(&cuFunc, cuModule, name));
    errcheck(cuLaunchKernel(cuFunc, blocksPerGrid, 1, 1,
        threadsPerBlock, 1, 1,
        0,
        NULL, args, NULL));
    errcheck(cuMemcpyDtoH(&r->data, d_res, fsize));
    cuMemFree(d_res);
    for (int i=0; i<argcv[0]; i++)
        cuMemFree(dps[i]);
    return (Object)r;
}
Ejemplo n.º 4
0
int room_goto(int indx)
{
  errcheck(indx,"Attempting to go to nonexisting room", 0);
  enigma::room_switching_id = indx;
  enigma::room_switching_restartgame = false;
  return 1;
}
Ejemplo n.º 5
0
void THInit()
{
	static int init;

	if(init)
		return;
	init_yuv2rgb();
#ifndef USEBLAS
	blas_init();
#endif
	init = 1;
#if defined CUDNN && defined USECUDAHOSTALLOC
	// cuda_maphostmem = 1 requires that memory was allocated with cudaHostAlloc
	// cuda_maphostmem = 2 will work with malloc, but Tegra TX1 does not support cudaHostRegister with cudaHostRegisterMapped
	struct cudaDeviceProp prop;

	cudaGetDeviceProperties(&prop, 0);
	if(prop.canMapHostMemory)
	{
		errcheck(cudaSetDeviceFlags(cudaDeviceMapHost));
		cuda_maphostmem = 1;
	}
#endif
#ifdef OPENCL
	thopencl_init();
#endif
}
Ejemplo n.º 6
0
int room_restart()
{
	int indx=(int)room.rval.d;
	errcheck(indx,"Is this some kind of joke?");
	enigma::roomdata[indx]->gotome();
	return 0;
}
Ejemplo n.º 7
0
int room_tile_add_ext(int indx, int bck, int left, int top, int width, int height, int x, int y, int depth, int xscale, int yscale, double alpha, int color)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomstruct *rm = enigma::roomdata[indx];
    const int tcount = rm->tilecount++;
    enigma::tile *ti = rm->tiles;
    enigma::tile *newtiles = new enigma::tile[tcount + 1];
    for (int tilei = 0; tilei < tcount; tilei++)
        newtiles[tilei] = ti[tilei];

    newtiles[tcount].id = enigma::maxtileid++;
    newtiles[tcount].bckid = bck;
    newtiles[tcount].bgx = left;
    newtiles[tcount].bgy = top;
    newtiles[tcount].depth = depth;
    newtiles[tcount].height = height;
    newtiles[tcount].width = width;
    newtiles[tcount].roomX = x;
    newtiles[tcount].roomY = y;
    newtiles[tcount].xscale = xscale;
    newtiles[tcount].yscale = yscale;
    newtiles[tcount].alpha = alpha;
    newtiles[tcount].color = color;

    if (enigma::tile_alter) delete[] rm->tiles;
    rm->tiles = newtiles;
    enigma::tile_alter = true;
    return 1;
}
Ejemplo n.º 8
0
int room_set_background_color(int indx, int col, bool show)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomdata[indx]->backcolor = col;
    enigma::roomdata[indx]->drawbackcolor = show;
    return 1;
}
Ejemplo n.º 9
0
int room_restart()
{
  int indx=(int)room.rval.d;
  errcheck(indx, "Is this some kind of joke?", 0);
  enigma::room_switching_id = indx;
  enigma::room_switching_restartgame = false;
  return 1;
}
Ejemplo n.º 10
0
THFloatTensor *cudnn_Threshold_updateOutput(struct module *module, THFloatTensor *input)
{
	THFloatTensor *output = module->output;
	cudnnTensorDescriptor_t dinput, doutput;
	int inplace = module->Threshold.inplace;
	float one = 1, zero = 0;

	errcheck(THcudnn_TensorDescriptor(&dinput, input));
	if(inplace)
		THFloatTensor_set(output, input);
	else THCudaTensor_resize4d(output, input->size[0], input->size[1], input->size[2], input->size[3]);
	errcheck(THcudnn_TensorDescriptor(&doutput, output));

	errcheck(cudnnActivationForward(THcudnn_getHandle(), CUDNN_ACTIVATION_RELU, &one, dinput, THFloatTensor_data(input), &zero,
		doutput, THFloatTensor_data(output)));

	cudnnDestroyTensorDescriptor(dinput);
	cudnnDestroyTensorDescriptor(doutput);
	return output;
}
Ejemplo n.º 11
0
int room_instance_clear(int indx)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomstruct *rm = enigma::roomdata[indx];
    enigma::inst *newinst = new enigma::inst[1];
    rm->instancecount = 0;

    if (enigma::instance_alter) delete[] rm->instances;
    rm->instances = newinst;
    enigma::instance_alter = true;
    return 1;
}
Ejemplo n.º 12
0
int room_tile_clear(int indx)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomstruct *rm = enigma::roomdata[indx];
    enigma::tile *newtiles = new enigma::tile[1];
    rm->tilecount = 0;

    if (enigma::tile_alter) delete[] rm->tiles;
    rm->tiles = newtiles;
    enigma::tile_alter = true;
    return 1;
}
Ejemplo n.º 13
0
THFloatTensor *cudnn_SpatialMaxPooling_updateOutput(struct module *module, THFloatTensor *input)
{
	int kW = module->SpatialMaxPooling.kW;
	int kH = module->SpatialMaxPooling.kH;
	int dW = module->SpatialMaxPooling.dW;
	int dH = module->SpatialMaxPooling.dH;
	int padW = module->SpatialMaxPooling.padW;
	int padH = module->SpatialMaxPooling.padH;

	THFloatTensor *output = module->output;
	cudnnTensorDescriptor_t dinput, doutput;
	cudnnPoolingDescriptor_t dpool;
	float one = 1, zero = 0;
	int sizes[4];

	errcheck(THcudnn_TensorDescriptor(&dinput, input));
	errcheck(cudnnCreatePoolingDescriptor(&dpool));
	errcheck(cudnnSetPooling2dDescriptor(dpool, CUDNN_POOLING_MAX, kH, kW, padH, padW, dH, dW));
	errcheck(cudnnGetPoolingNdForwardOutputDim(dpool, dinput, 4, sizes));
	THCudaTensor_resize4d(output, sizes[0], sizes[1], sizes[2], sizes[3]);
	errcheck(THcudnn_TensorDescriptor(&doutput, output));

	errcheck(cudnnPoolingForward(THcudnn_getHandle(), dpool, &one, dinput, THFloatTensor_data(input), &zero,
		doutput, THFloatTensor_data(output)));

	cudnnDestroyTensorDescriptor(dinput);
	cudnnDestroyTensorDescriptor(doutput);
	cudnnDestroyPoolingDescriptor(dpool);
	return output;
}
Ejemplo n.º 14
0
int main(int argc, char* argv[])
{
  if (argc !=4)
    usage();
  string hostsFile=argv[1];
  ifstream diff(argv[2]);
  port = (unsigned short)atoi(argv[3]);
  if (diff.fail()) {
    cerr << "error: open diff file" << endl;
    usage();
  }
  if (verbose) cout << "Reading diff..." << endl;
  assert(readChanges(diff));
  if (verbose) cout << "Reading core info..." << endl;
  assert(getCores(hostsFile));
  diff.close();
  if (verbose) cout << "Getting addresses..."<<endl;
  errcheck(getAddrs());
  if (verbose) cout << "Constructing stage data..."<<endl;
  errcheck(makeStages());
  if (verbose) cout << "Opening connections..." << endl;
  errcheck(initConnections());
  
  if (verbose) cout << "Transferring stage data..." << endl;
  errcheck(sendStages());
  int i;
  for (i=0;i<3;i++) {
    if (verbose) cout << "Doing stage " << i << "..."<<endl;
    errcheck(doStage(i));
  }
  if (verbose) cout << "Closing connections..." <<endl;
  errcheck(finishConnections());
  if (verbose) cout<<"Reassign complete."<<endl;
}
Ejemplo n.º 15
0
Cell *arith(Node **a, int n)	/* a[0] + a[1], etc.  also -a[0] */
{
	Awkfloat i, j = 0;
	double v;
	Cell *x, *y, *z;

	x = execute(a[0]);
	i = getfval(x);
	tempfree(x);
	if (n != UMINUS) {
		y = execute(a[1]);
		j = getfval(y);
		tempfree(y);
	}
	z = gettemp();
	switch (n) {
	case ADD:
		i += j;
		break;
	case MINUS:
		i -= j;
		break;
	case MULT:
		i *= j;
		break;
	case DIVIDE:
		if (j == 0)
			ERROR "division by zero" FATAL;
		i /= j;
		break;
	case MOD:
		if (j == 0)
			ERROR "division by zero in mod" FATAL;
		modf(i/j, &v);
		i = i - j * v;
		break;
	case UMINUS:
		i = -i;
		break;
	case POWER:
		if (j >= 0 && modf(j, &v) == 0.0)	/* pos integer exponent */
			i = ipow(i, (int) j);
		else
			i = errcheck(pow(i, j), "pow");
		break;
	default:	/* can't happen */
		ERROR "illegal arithmetic operator %d", n FATAL;
	}
	setfval(z, i);
	return(z);
}
Ejemplo n.º 16
0
int room_set_background(int indx, int bind, bool vis, bool fore, bool back, double x, double y, bool htiled, bool vtiled, double hspeed, double vspeed, double alpha, int color)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::backstruct &bk = enigma::roomdata[indx]->backs[bind];
    bk.visible = vis;
    bk.foreground = fore;
    bk.background = back;
    bk.area_x = x;
    bk.area_y = y;
    bk.tileHor = htiled;
    bk.tileVert = vtiled;
    bk.horSpeed = hspeed;
    bk.verSpeed = vspeed;
    bk.alpha = alpha;
    bk.color = color;
    return 1;
}
Ejemplo n.º 17
0
real rnk3ccrdata::updatecrt(direction dir,vind varind,partialdata* newdtpnt,bool& reliable,const double tol,const double rqbound) const 
{  
	partialrnk3ccrdata *newdata = static_cast<partialrnk3ccrdata *>(newdtpnt);    
	
	/* Attention: newdtpnt MUST point to partialrnk3ccrdata object !!!
	   For safety, in debug mode use the alternative code with dynamic_cast and assert     */
	
/*	partialrnk3ccrdata *newdata = dynamic_cast<partialrnk3ccrdata *>(pdt);
	assert(newdata);                                                            */

	real newwilksst,newbartpist,newccr12;
	real e1 = (*emat)(varind,varind);
	real *tv = newdata->getlhtmpv(),hei1,*rpl[4];
	real newlawhotst = lawhotst;

	updatest(newwilksst,newbartpist,varind,newdata,reliable,tol);
	for (vind i=0;i<3;i++) {
		hei1 = heinv[i][varind]; 
		rpl[i] = &(tv[i] = hei1 / e1);
		newlawhotst += tv[i]*hei1;  
	}

	#ifdef COUNTING 
	fpcnt1 += 6;
	#endif

	if (reliable) {  
		rpl[3] = &newlawhotst; 
		reliable = errcheck(rpl,tol,4); 
	}  
	
	if (dir==forward) newdata->nvar=nvar+1 ; 
	else newdata->nvar=nvar-1;
	
	if (newdata->nvar == 1) newccr12 = newbartpist; 
 	else if (newdata->nvar == 2)  
		newccr12 = 0.5 * ( newbartpist +  std::sqrt(static_cast<real>(newbartpist*newbartpist -4.*(newbartpist+newwilksst-1.))) );
	else newccr12 = findccr12(newwilksst,newbartpist,newlawhotst,rqbound);
	newdata->setlawhot(newlawhotst);
	newdata->setcrt(newccr12);

	return newccr12;
} 
Ejemplo n.º 18
0
int room_set_view(int indx, int vind, int vis, int xview, int yview, int wview, int hview, int xport, int yport, int wport, int hport, int hborder, int vborder, int hspeed, int vspeed, int obj)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::viewstruct &vw = enigma::roomdata[indx]->views[vind];
    vw.start_vis = vis;
    vw.area_x = xview;
    vw.area_y = yview;
    vw.area_w = wview;
    vw.area_h = hview;
    vw.port_x = xport;
    vw.port_y = yport;
    vw.port_w = wport;
    vw.port_h = hport;
    vw.hborder = hborder;
    vw.vborder = vborder;
    vw.hspd = hspeed;
    vw.vspd = vspeed;
    vw.object2follow = obj;
    return 1;
}
Ejemplo n.º 19
0
int room_instance_add(int indx, int x, int y, int obj)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomstruct *rm = enigma::roomdata[indx];
    const int icount = rm->instancecount++;
    enigma::inst *in = rm->instances;
    enigma::inst *newinst = new enigma::inst[icount + 1];
    for (int insti = 0; insti < icount; insti++)
        newinst[insti] = in[insti];

    newinst[icount].id = enigma::maxid++;
    newinst[icount].x = x;
    newinst[icount].y = y;
    newinst[icount].obj = obj;

    if (enigma::instance_alter) delete[] rm->instances;
    rm->instances = newinst;
    enigma::instance_alter = true;
    return 1;
}
Ejemplo n.º 20
0
tBitmapDirectory* BDAddDirectory(
      Widget w,
      String directory,
      tBitmapDirectory *bd) {
  DIR *dir;
  struct dirent *dp;
  struct stat statbuf;
  char fullfilename[BUFSIZE];

  dir = (DIR *)errcheck_ptr(opendir(directory), NULL, directory);
  for(dp = readdir(dir); dp; dp = readdir(dir))
    if(dp->d_name[0] != '.') { /* Ignore files starting with '.' */
      sprintf(fullfilename, "%s/%s", directory, dp->d_name);
      stat(fullfilename, &statbuf);
      if(statbuf.st_mode & S_IFDIR)
	/* Subdirectory, so add it... */
	bd = BDAddDirectory(w, fullfilename, bd);
      else
	bd = AddFile(w, fullfilename, dp->d_name, bd);
    }
  (void)errcheck((int)closedir(dir), -1, directory);
  return(bd);
}
Ejemplo n.º 21
0
SQLRETURN ood_SQLFetch(hStmt_T * stmt)
{
	sword ret = OCI_SUCCESS;
	sword tmp = OCI_SUCCESS;
	int offset;
	unsigned int i, row;

	SQLRETURN status = stmt->fetch_status;

	stmt->num_fetched_rows = -1;

#ifdef UNIX_DEBUG
	signal(SIGSEGV, SIG_DFL);
#endif

	/* 
	 * We have a mapping problem between ODBC and OCI here. 
	 * OCIStmtExecute is equivalent to SQLExecute,SQLFetch. 
	 * OCIStmtFetch returns OCI_NO_DATA when it hits the end of the result
	 * set whereas SQLFetch returns SQL_NO_DATA when you try to go past
	 * the end of the result set. Of of this mesna there is a lot of twiddling
	 * to be done in here.
	 *
	 * NOTE: alt_fetch functions simply return OCI_SUCCESS if there is data
	 * to be processed, OCI_NO_DATA if not.
	 */
	if (stmt->alt_fetch) {
		ret = stmt->alt_fetch(stmt);
		if (ret == OCI_NO_DATA) {
			stmt->fetch_status = SQL_NO_DATA;
			if (stmt->rows_fetched_ptr)
				*stmt->rows_fetched_ptr =
				    stmt->num_fetched_rows;
			return (SQL_NO_DATA);
		}
		status = stmt->fetch_status;
	} else {
		if (status != SQL_NO_DATA && stmt->bookmark) {
			/*
			 * stmt->bookmark would be nonzero if this wasn't the first call
			 * to SQLFetch. As OCIStmtExec==SQLexecute,SQLFetch we don't want
			 * to call OCIStmtFetch for the first call of SQLFetch.
			 * if status==SQL_NO_DATA we're trying to go past the end of the
			 * result set. If we were to call OCIStmtFetch now we'd get 
			 * an error.
			 */
			ret =
			    OCIStmtFetch_log_stat(stmt->oci_stmt,
						  stmt->dbc->oci_err,
						  stmt->row_array_size,
						  OCI_FETCH_NEXT, OCI_DEFAULT,
						  ret);
#ifdef UNIX_DEBUG
			errcheck(__FILE__, __LINE__, ret, stmt->dbc->oci_err);
#endif

			OCIAttrGet_log_stat(stmt->oci_stmt, OCI_HTYPE_STMT,
					    &stmt->num_result_rows, 0,
					    OCI_ATTR_ROW_COUNT,
					    stmt->dbc->oci_err, tmp);
		} else if (status == SQL_NO_DATA && !stmt->bookmark) {
			/* 
			 * This means the OCIStmtExecute returned OCI_NO_DATA, ie the 
			 * result set<=array size. This is equivalent here to 
			 * OCIStmtFetch returning OCI_NO_DATA at the end of a larger 
			 * result set. 
			 */
			status = SQL_SUCCESS;
			ret = OCI_NO_DATA;
		}
	}

	if (ret && ret != OCI_NO_DATA) {
		/*
		 * OCIStmtFetch has returned an error.
		 */
		if (ret == OCI_ERROR || ret == OCI_SUCCESS_WITH_INFO) {
			ood_driver_error(stmt, ret, __FILE__, __LINE__);
			status = SQL_ERROR;
		}
	} else {
		/*
		 * Either OCIStmtFetch returned OCI_NO_DATA or OCIStmtExecute
		 * returned OCI_NO_DATA or OCIStmtExecute and OCIStmtFetch (if
		 * called) returned OCI_SUCCESS
		 */
		if (ret == OCI_NO_DATA) {
			stmt->num_fetched_rows = stmt->num_result_rows
			    % stmt->row_array_size;
			stmt->fetch_status = SQL_NO_DATA;
			if (!stmt->num_fetched_rows)	/* landed on a boundary */
				status = SQL_NO_DATA;
		} else {
			if (stmt->num_fetched_rows == -1) {
				if (status == SQL_NO_DATA)	/* Nothing fetched, obviously */
					stmt->num_fetched_rows = 0;
				else
					stmt->num_fetched_rows =
					    stmt->row_array_size;
			}
		}

		stmt->current_row = 0;
		if (stmt->row_bind_offset_ptr)
			offset = *((SQLUINTEGER *) stmt->row_bind_offset_ptr);
		else
			offset = 0;

		for (row = 0; row < stmt->row_array_size; row++) {
			stmt->current_row++;
			stmt->bookmark++;

#ifdef UNIX_DEBUG
			fprintf(stderr, "Fetching row %d of num_fetched %d\n",
				row, stmt->num_fetched_rows);
#endif

			if (stmt->row_status_ptr
			    && (signed)row < stmt->num_fetched_rows) {
				stmt->row_status_ptr[row] =
				    (SQLSMALLINT) SQL_ROW_SUCCESS;
			} else if ((signed)row >= stmt->num_fetched_rows) {
				if (stmt->row_status_ptr) {
					stmt->row_status_ptr[row] = SQL_NO_DATA;
				}
				continue;
			}
			if (stmt->current_ir->lob_col_flag) {
				for (i = 1; i <= stmt->current_ir->num_recs;
				     i++) {
					stmt->current_ir->recs.ir[i].posn = 1;
				}
			}

			if (stmt->current_ar->bound_col_flag)
				/* There are bound columns... */
			{

				for (i = 1; i <= stmt->current_ar->num_recs;
				     i++) {
					if (stmt->current_ar->recs.ar[i].
					    data_ptr) {
						if (!stmt->current_ir->recs.
						    ir[i].ind_arr[row]) {
							/*
							 *stmt->current_ar->recs.ar[i].bind_indicator=
							 stmt->current_ir->recs.ir[i].data_size;
							 */
							if (ENABLE_TRACE) {
								ood_log_message
								    (stmt->dbc,
								     __FILE__,
								     __LINE__,
								     TRACE_FUNCTION_EXIT,
								     (SQLHANDLE)
								     NULL,
								     status,
								     "iihi",
								     "BoundColNo",
								     i,
								     "BufferLength",
								     stmt->
								     current_ar->
								     recs.ar[i].
								     buffer_length,
								     "Data Pointer",
								     (long)
								     stmt->
								     current_ar->
								     recs.ar[i].
								     data_ptr,
								     "Bind Indicator",
								     *stmt->
								     current_ar->
								     recs.ar[i].
								     bind_indicator);
							}
							/*
							 * And finally call the conversion function!
							 *
							 * ...yes, we're going for the "most stupidly 
							 * complicated function call in history" award
							 */
							status |=
							    stmt->current_ir->
							    recs.ir[i].
							    default_copy(row,
									 &stmt->
									 current_ir->
									 recs.
									 ir[i],
									 ((unsigned char *)
									  stmt->
									  current_ar->
									  recs.
									  ar[i].
									  data_ptr)
									 +
									 (row *
									  stmt->
									  current_ar->
									  recs.
									  ar[i].
									  buffer_length)
									 +
									 offset,
									 stmt->
									 current_ar->
									 recs.
									 ar[i].
									 buffer_length
									 +
									 offset,
									 stmt->
									 current_ar->
									 recs.
									 ar[i].
									 bind_indicator
									 +
									 offset);
						} else {	/* if null */

							if (ENABLE_TRACE) {
								ood_log_message
								    (stmt->dbc,
								     __FILE__,
								     __LINE__,
								     TRACE_FUNCTION_EXIT,
								     (SQLHANDLE)
								     NULL,
								     status,
								     "iihs",
								     "BoundColNo",
								     i,
								     "BufferLength",
								     stmt->
								     current_ar->
								     recs.ar[i].
								     buffer_length,
								     "Data Pointer",
								     (long)
								     stmt->
								     current_ar->
								     recs.ar[i].
								     data_ptr,
								     "Null Field Status",
								     "Column is NULL");
							}
							*stmt->current_ar->recs.
							    ar[i].
							    bind_indicator =
							    SQL_NULL_DATA;
						}
					}	/* if ar->data_ptr */
				}	/* for num_recs */
			}	/* if bound columns */
		}		/* for rows */
	}			/* if results */

	if (stmt->rows_fetched_ptr)
		*stmt->rows_fetched_ptr = stmt->num_fetched_rows;

	return status;
}
Ejemplo n.º 22
0
double Exp(double x)
{
    return errcheck(exp(x), "exp");
}
Ejemplo n.º 23
0
int room_duplicate(int indx, bool ass, int assroom)
{
    errcheck(indx,"Nonexistent room", 0);
    if (ass) {
        errcheck(assroom,"Nonexistent room", 0);
    }
    int newrm = (ass)?enigma::room_idmax++ : enigma::room_idmax - 1;

    enigma::roomstruct** newroomdata;
    newroomdata = new enigma::roomstruct*[newrm + 1];
    for (int i = 0; i < newrm; i++)
        newroomdata[i] = enigma::roomdata[i];

    enigma::roomstruct *rm = (ass)?newroomdata[indx] : newroomdata[newrm] = new enigma::roomstruct;
    enigma::roomstruct *copyrm = (ass)?enigma::roomdata[assroom]:enigma::roomdata[indx];

    rm->id = copyrm->id;
    rm->order = (ass)?copyrm->order:-1;
    rm->name = "New Room";
    rm->cap = copyrm->cap;
    rm->backcolor = copyrm->backcolor;
    rm->drawbackcolor = copyrm->drawbackcolor;
    rm->width = copyrm->width;
    rm->height = copyrm->height;
    rm->spd = copyrm->spd;
    rm->persistent = copyrm->persistent;
    rm->views_enabled = copyrm->views_enabled;
    rm->createcode = copyrm->createcode;
    rm->precreatecode = copyrm->precreatecode;
    
    enigma::inst *newinst = new enigma::inst[copyrm->instancecount];
    rm->instances = newinst;
    rm->instancecount = copyrm->instancecount;
    for (int i = 0; i < rm->instancecount; i++)
        rm->instances[i] = copyrm->instances[i];

    enigma::tile *newtiles = new enigma::tile[copyrm->tilecount];
    rm->tiles = newtiles;
    rm->tilecount = copyrm->tilecount;
    for (int i = 0; i < rm->tilecount; i++)
        rm->tiles[i] = copyrm->tiles[i];

    enigma::viewstruct vw, vc;
    for (int i = 0; i < 8; i++)
    {
        vw = rm->views[i];
        vc = copyrm->views[i];
        vw.start_vis = vc.start_vis;
        vw.area_x = vw.area_x;
        vw.area_y = vc.area_y;
        vw.area_w = vc.area_w;
        vw.area_h = vc.area_h;
        vw.port_x = vc.port_x;
        vw.port_y = vc.port_y;
        vw.port_w = vc.port_w;
        vw.port_h = vc.port_h;
        vw.hborder = vc.hborder;
        vw.vborder = vc.vborder;
        vw.hspd = vc.hspd;
        vw.vspd = vc.vspd;
        vw.object2follow = vc.object2follow;
    }

    enigma::backstruct bk, bc;
    for (int i = 0; i < 8; i++)
    {
        bk = rm->backs[i];
        bc = copyrm->backs[i];
        bk.visible = bc.visible;
        bk.foreground = bc.foreground;
        bk.background = bc.background;
        bk.area_x = bc.area_x;
        bk.area_y = bc.area_y;
        bk.tileHor = bc.tileHor;
        bk.tileVert = bc.tileVert;
        bk.horSpeed = bc.horSpeed;
        bk.verSpeed = bc.verSpeed;
        bk.alpha = bc.alpha;
        bk.color = bc.color;
    }

    delete[] enigma::roomdata;
    enigma::roomdata = newroomdata;
    return ((ass)?indx:newrm);
}
Ejemplo n.º 24
0
string room_get_name(int indx)
{
  errcheck(indx,"Room index out of range", "");
  return enigma::roomdata[indx]->name;
}
Ejemplo n.º 25
0
Object cuda_using_do_blockWidth_blockHeight_gridWidth_gridHeight(Object self, int nparts, int *argcv,
        Object *argv, int flags) {
    CUresult error;
    cuInit(0);
    int deviceCount = 0;
    error = cuDeviceGetCount(&deviceCount);
    if (deviceCount == 0) {
        raiseError("No CUDA devices found");
    }
    CUdevice cuDevice;
    CUcontext cuContext;
    CUmodule cuModule;
    CUfunction cuFunc;
    error = cuDeviceGet(&cuDevice, 0);
    error = cuCtxCreate(&cuContext, 0, cuDevice);
    // do through gridWidth only have one argument each
    int argOffset = argcv[0] + 1;
    int blockDimX = integerfromAny(argv[argOffset++]);
    int blockDimY = integerfromAny(argv[argOffset++]);
    int gridDimX = integerfromAny(argv[argOffset++]);
    int gridDimY = integerfromAny(argv[argOffset++]);

    char *tmp = grcstring(argv[argcv[0]]);
    char argStr[strlen(tmp) + 1];
    strcpy(argStr, tmp);
    char *tmp2 = strtok(argStr, " ");
    char blockname[128];
    strcpy(blockname, tmp2);
    errcheck(cuModuleLoad(&cuModule, blockname));
    CUdeviceptr dps[argcv[0]];
    float floats[argcv[0]];
    void *args[argcv[0]];
    int ints[argcv[0]];
    argStr[strlen(blockname)] = ' ';
    strtok(argStr, " ");
    for (int i=0; i<argcv[0]; i++) {
        char *argType = strtok(NULL, " ");
        if (argType[0] == 'f' && argType[1] == '*') {
            struct CudaFloatArray *a = (struct CudaFloatArray *)argv[i];
            errcheck(cuMemAlloc(&dps[i], a->size * sizeof(float)));
            errcheck(cuMemcpyHtoD(dps[i], &a->data, a->size * sizeof(float)));
            args[i] = &dps[i];
        } else if (argType[0] == 'f') {
            floats[i] = (float)*((double *)(argv[i]->data));
            args[i] = &floats[i];
        } else if (argType[0] == 'i') {
            ints[i] = integerfromAny(argv[i]);
            args[i] = &ints[i];
        } else {
            // Fail
            char buf[256];
            sprintf(buf, "CUDA argument cannot be coerced. This shouldn't happen. Argument string: %s\n", argType);
            raiseError(buf);
        }
    }
    char name[256];
    strcpy(name, "block");
    strcat(name, blockname + strlen("_cuda/"));
    for (int i=0; name[i] != 0; i++)
        if (name[i] == '.') {
            name[i] = 0;
            break;
        }
    errcheck(cuModuleGetFunction(&cuFunc, cuModule, name));
    errcheck(cuLaunchKernel(cuFunc, gridDimX, gridDimY, 1,
        blockDimX, blockDimY, 1,
        0,
        NULL, args, NULL));
    for (int i=0; i<argcv[0]; i++) {
        struct CudaFloatArray *a = (struct CudaFloatArray *)argv[i];
        errcheck(cuMemcpyDtoH(&a->data, dps[i], a->size * sizeof(float)));
        cuMemFree(dps[i]);
    }
    return alloc_none();
}
Ejemplo n.º 26
0
int room_set_width(int indx, int wid)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomdata[indx]->width = wid;
    return 1;
}
Ejemplo n.º 27
0
int room_set_view_enabled(int indx, int val)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomdata[indx]->views_enabled = val;
    return 1;
}
Ejemplo n.º 28
0
int room_set_persistent(int indx, bool pers)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomdata[indx]->persistent = pers;
    return 1;
}
Ejemplo n.º 29
0
int room_set_caption(int indx, string str)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomdata[indx]->cap = str;
    return 1;
}
Ejemplo n.º 30
0
int room_set_height(int indx, int hei)
{
    errcheck(indx,"Nonexistent room", 0);
    enigma::roomdata[indx]->height = hei;
    return 1;
}