Exemplo n.º 1
0
/*
 * GetNextThread -
 * NB - callers must continue to call this function until it returns FALSE
 */
BOOL GetNextThread( ThreadList *info, ThreadPlace *place,
                    DWORD pid, BOOL first )
{

    DWORD                       curpid;
    PERF_COUNTER_DEFINITION     *counter;
    BOOL                        error;

    error = FALSE;
    if( first ) {
        beginRead( FALSE );
        initObj( &regData, &threadObject, N_THREAD );
        if( threadObject == NULL ) error = TRUE;
        if( !error ) {
            place->index = 0;
            place->obj = threadObject;
            place->pid = pid;
            place->inst = getFirstInstance( threadObject );
        }
    } else {
        place->index ++;
        if( place->index < place->obj->NumInstances ) {
            place->inst = getNextInstance( place->inst );
        }
    }
    if( !error ) {
        counter = findCounter( place->obj, N_PROCID );
        if( counter == NULL ) error = TRUE;
    }
    if( !error ) {
        for( ; place->index < place->obj->NumInstances; place->index ++ ) {
            if( place->inst == NULL ) {
                error = TRUE;
                break;
            }
            curpid = getCounterDWORD( place->inst, counter );
            if( curpid == place->pid ) break;
            place->inst = getNextInstance( place->inst );
        }
    }
    if( !error && place->index >= place->obj->NumInstances ) error = TRUE;
    if( !error ) {
        counter = findCounter( place->obj, N_THREADID );
        if( counter == NULL ) error = TRUE;
    }
    if( !error ) {
        info->tid = getCounterDWORD( place->inst, counter );
        counter = findCounter( place->obj, N_BASE_PRIORITY );
        if( counter == NULL ) error = TRUE;
    }
    if( !error ) {
        info->priority = getCounterDWORD( place->inst, counter );
    } else {
        endRead( FALSE );
    }
    return( !error );
}
Exemplo n.º 2
0
void ObjObject::initialize()
{
	textureObject = setupTexture( textureName );

	buildShaderProgram();
	glUseProgram(shaderProgram);
	
	initObj();
}
Exemplo n.º 3
0
int main(int argc, char * argv[]) {
   PV_Init initObj(&argc, &argv, false/*allowUnrecognizedArguments*/);
   initObj.initialize();
   PV::MLPRegisterKeywords(&initObj);
   initObj.registerKeyword("BatchNormTestProbe", PV::createBatchNormTestProbe);
   int rank = initObj.getWorldRank();
   int status = buildandrun(&initObj, NULL, NULL);

   return status==PV_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
}
Exemplo n.º 4
0
Value wrenNewRange(WrenVM* vm, double from, double to, bool isInclusive)
{
  ObjRange* range = allocate(vm, sizeof(ObjRange) + 16);
  initObj(vm, &range->obj, OBJ_RANGE, vm->rangeClass);
  range->from = from;
  range->to = to;
  range->isInclusive = isInclusive;

  return OBJ_VAL(range);
}
Exemplo n.º 5
0
Upvalue* wrenNewUpvalue(WrenVM* vm, Value* value)
{
  Upvalue* upvalue = allocate(vm, sizeof(Upvalue));
  initObj(vm, &upvalue->obj, OBJ_UPVALUE);

  upvalue->value = value;
  upvalue->closed = NULL_VAL;
  upvalue->next = NULL;
  return upvalue;
}
Exemplo n.º 6
0
/*
 * GetThreadInfo
 */
BOOL GetThreadInfo( DWORD pid, DWORD tid, ThreadStats *info ) {

    PERF_COUNTER_DEFINITION     *pid_counter;
    PERF_COUNTER_DEFINITION     *tid_counter;
    PERF_COUNTER_DEFINITION     *counter;
    PERF_INSTANCE_DEFINITION    *inst;
    DWORD                       curid;
    DWORD                       i;
    BOOL                        error;

    error = FALSE;
    beginRead( FALSE );
    initObj( &regData, &threadObject, N_THREAD );
    if( threadObject == NULL ) {
        error = TRUE;
    }
    if( !error ) {
        pid_counter = findCounter( threadObject, N_PROCID );
        tid_counter = findCounter( threadObject, N_THREADID );
        if( pid_counter == NULL || tid_counter == NULL ) error = TRUE;
    }
    if( !error ) {
        inst = getFirstInstance( threadObject );
        for( i=0; i < threadObject->NumInstances; i++ ) {
            if( inst == NULL ) {
                error = TRUE;
                break;
            }
            curid = getCounterDWORD( inst, tid_counter );
            if( curid == tid ) {
                curid = getCounterDWORD( inst, pid_counter );
                if( curid == pid ) break;
            }
            inst = getNextInstance( inst );
        }
    }
    if( !error && i == threadObject->NumInstances ) {
         error = TRUE;
    } else {
        info->tid = tid;
        info->pid = pid;
        counter = findCounter( threadObject, N_BASE_PRIORITY );
        info->base_pri = getCounterDWORD( inst, counter );
        counter = findCounter( threadObject, N_CUR_PRIORITY );
        info->cur_pri = getCounterDWORD( inst, counter );
        counter = findCounter( threadObject, N_THREAD_STATE );
        info->state = getCounterDWORD( inst, counter );
        counter = findCounter( threadObject, N_WAIT_REASON );
        info->wait_reason = getCounterDWORD( inst, counter );
    }
    endRead( FALSE );
    return( !error );
}
Exemplo n.º 7
0
Upvalue* wrenNewUpvalue(WrenVM* vm, Value* value)
{
  Upvalue* upvalue = allocate(vm, sizeof(Upvalue));

  // Upvalues are never used as first-class objects, so don't need a class.
  initObj(vm, &upvalue->obj, OBJ_UPVALUE, NULL);

  upvalue->value = value;
  upvalue->closed = NULL_VAL;
  upvalue->next = NULL;
  return upvalue;
}
Exemplo n.º 8
0
Value wrenNewUninitializedString(WrenVM* vm, size_t length)
{
  // Allocate before the string object in case this triggers a GC which would
  // free the string object.
  char* heapText = allocate(vm, length + 1);

  ObjString* string = allocate(vm, sizeof(ObjString));
  initObj(vm, &string->obj, OBJ_STRING, vm->stringClass);
  string->value = heapText;

  return OBJ_VAL(string);
}
Exemplo n.º 9
0
ObjClass* wrenNewSingleClass(WrenVM* vm, int numFields, ObjString* name)
{
  ObjClass* classObj = allocate(vm, sizeof(ObjClass));
  initObj(vm, &classObj->obj, OBJ_CLASS, NULL);
  classObj->superclass = NULL;
  classObj->numFields = numFields;
  classObj->name = name;

  WREN_PIN(vm, classObj);
  wrenMethodBufferInit(vm, &classObj->methods);
  WREN_UNPIN(vm);
  
  return classObj;
}
Exemplo n.º 10
0
ObjClass* wrenNewSingleClass(WrenVM* vm, int numFields, ObjString* name)
{
  ObjClass* classObj = ALLOCATE(vm, ObjClass);
  initObj(vm, &classObj->obj, OBJ_CLASS, NULL);
  classObj->superclass = NULL;
  classObj->numFields = numFields;
  classObj->name = name;

  wrenPushRoot(vm, (Obj*)classObj);
  wrenMethodBufferInit(&classObj->methods);
  wrenPopRoot(vm);

  return classObj;
}
Exemplo n.º 11
0
/*
 *  ======== Timer_reconfig ========
 *  1. Init obj using params
 *  2. Reconfig Hwi
 *  3. Timer_init()
 *  4. Timer configuration (wrt emulation, external frequency etc)
 *  5. Timer_setPeriod()
 *  6. Timer_start()
 */
Void Timer_reconfig(Timer_Object *obj, Timer_FuncPtr tickFxn,
        const Timer_Params *params, Error_Block *eb)
{
    initObj(obj, tickFxn, params);

    /* since timer requires a stub func, no Hwi reconfig is needed */

    /* leave it to caller to check eb */
    postInit(obj, eb);
    
    if (obj->startMode == Timer_StartMode_AUTO) {
        Timer_start(obj);
    }
}
Exemplo n.º 12
0
ObjClosure* wrenNewClosure(WrenVM* vm, ObjFn* fn)
{
  ObjClosure* closure = allocate(vm,
      sizeof(ObjClosure) + sizeof(Upvalue*) * fn->numUpvalues);
  initObj(vm, &closure->obj, OBJ_CLOSURE, vm->fnClass);

  closure->fn = fn;

  // Clear the upvalue array. We need to do this in case a GC is triggered
  // after the closure is created but before the upvalue array is populated.
  for (int i = 0; i < fn->numUpvalues; i++) closure->upvalues[i] = NULL;

  return closure;
}
Exemplo n.º 13
0
Value wrenNewInstance(WrenVM* vm, ObjClass* classObj)
{
  ObjInstance* instance = allocate(vm,
      sizeof(ObjInstance) + classObj->numFields * sizeof(Value));
  initObj(vm, &instance->obj, OBJ_INSTANCE, classObj);

  // Initialize fields to null.
  for (int i = 0; i < classObj->numFields; i++)
  {
    instance->fields[i] = NULL_VAL;
  }

  return OBJ_VAL(instance);
}
Exemplo n.º 14
0
METHODPREFIX(CLASS, void, init)(ST_ARGS, jobject byteBuffer, jlong size, jboolean synchronize)
{
	void * base=env->GetDirectBufferAddress(byteBuffer);
	mspace space=create_mspace_with_base(base, size, synchronize?1:0);
	if(space==NULL)
	{
		JNU_ThrowByName(env, EXCCLASS, "Error creating mspace in buffer (buffer size too small?)");
	}
	initObj(env, obj, "ptr", sizeof(JNISTRUCT));
	FID=getLongFieldId(env, obj, "ptr");
	MYHEADID(JNISTRUCT, FID);
	str->space=space;
	str->base=base;
	str->size=size;
}
Exemplo n.º 15
0
int main(int argc, char * argv[]) {
   int status;
   PV_Init initObj(&argc, &argv, false/*allowUnrecognizedArguments*/);
   if (initObj.getParams()==NULL) {
      initObj.setParams("input/KernelActivationTest-fullData.params");
      status = buildandrun(&initObj);
      if (status==PV_SUCCESS) {
         initObj.setParams("input/KernelActivationTest-maskData.params");
         status = rebuildandrun(&initObj);
      }
   }
   else {
      status = buildandrun(&initObj);
   }
   return status;
}
Exemplo n.º 16
0
ObjFn* wrenNewFunction(WrenVM* vm, Value* constants, int numConstants,
                       int numUpvalues, int numParams,
                       uint8_t* bytecode, int bytecodeLength,
                       ObjString* debugSourcePath,
                       const char* debugName, int debugNameLength,
                       int* sourceLines)
{
  // Allocate these before the function in case they trigger a GC which would
  // free the function.
  Value* copiedConstants = NULL;
  if (numConstants > 0)
  {
    copiedConstants = allocate(vm, sizeof(Value) * numConstants);
    for (int i = 0; i < numConstants; i++)
    {
      copiedConstants[i] = constants[i];
    }
  }

  FnDebug* debug = allocate(vm, sizeof(FnDebug));

  debug->sourcePath = debugSourcePath;

  // Copy the function's name.
  debug->name = allocate(vm, debugNameLength + 1);
  strncpy(debug->name, debugName, debugNameLength);
  debug->name[debugNameLength] = '\0';

  debug->sourceLines = sourceLines;
  
  ObjFn* fn = allocate(vm, sizeof(ObjFn));
  initObj(vm, &fn->obj, OBJ_FN, vm->fnClass);

  // TODO: Should eventually copy this instead of taking ownership. When the
  // compiler grows this, its capacity will often exceed the actual used size.
  // Copying to an exact-sized buffer will save a bit of memory. I tried doing
  // this, but it made the "for" benchmark ~15% slower for some unknown reason.
  fn->bytecode = bytecode;
  fn->constants = copiedConstants;
  fn->numUpvalues = numUpvalues;
  fn->numConstants = numConstants;
  fn->numParams = numParams;
  fn->bytecodeLength = bytecodeLength;
  fn->debug = debug;

  return fn;
}
Exemplo n.º 17
0
ObjList* wrenNewList(WrenVM* vm, int numElements)
{
  // Allocate this before the list object in case it triggers a GC which would
  // free the list.
  Value* elements = NULL;
  if (numElements > 0)
  {
    elements = allocate(vm, sizeof(Value) * numElements);
  }

  ObjList* list = allocate(vm, sizeof(ObjList));
  initObj(vm, &list->obj, OBJ_LIST, vm->listClass);
  list->capacity = numElements;
  list->count = numElements;
  list->elements = elements;
  return list;
}
Exemplo n.º 18
0
int main(int argc, char * argv[]) {
   int rank = 0;
   PV_Init initObj(&argc, &argv, false/*allowUnrecognizedArguments*/);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   char const * paramFile1 = "input/GenerateOutput.params";
   char const * paramFile2 = "input/TestOutput.params";
   char const * outputDir1 = "outputGenerate";
   char const * outputDir2 = "outputTest";
   int status = PV_SUCCESS;
   if (initObj.getParams()!=NULL) {
      if (rank==0) {
         pvErrorNoExit(errorMessage);
         errorMessage.printf("%s should be run without the params file argument.\n", initObj.getProgramName());
         errorMessage.printf("This test uses two hard-coded params files, %s and %s. The first generates an output pvp file, and the second checks whether the output is consistent with the input.\n",
               paramFile1, paramFile2);
      }
      MPI_Barrier(MPI_COMM_WORLD);
      exit(EXIT_FAILURE);
   }

   if (rank==0) {
      char const * rmcommand = "rm -rf outputGenerate outputTest";
      status = system(rmcommand);
      if (status != 0) {
         pvError().printf("deleting old output directories failed: \"%s\" returned %d\n", rmcommand, status);
      }
   }

   initObj.registerKeyword("TestNotAlwaysAllZerosProbe", createTestNotAlwaysAllZerosProbe);
   initObj.registerKeyword("TestAllZerosProbe", createTestAllZerosProbe);

   initObj.setParams(paramFile1);
   status = rebuildandrun(&initObj);
   if( status != PV_SUCCESS ) {
      pvError().printf("%s: rank %d running with params file %s returned error %d.\n", initObj.getProgramName(), rank, paramFile1, status);
   }

   initObj.setParams(paramFile2);

   status = rebuildandrun(&initObj, NULL, &checkProbesOnExit);
   if( status != PV_SUCCESS ) {
      pvErrorNoExit().printf("%s: rank %d running with params file %s returned status %d.\n", initObj.getProgramName(), rank, paramFile2, status);
   }

   return status==PV_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
}
Exemplo n.º 19
0
Value wrenNewString(WrenVM* vm, const char* text, size_t length)
{
  // Allocate before the string object in case this triggers a GC which would
  // free the string object.
  char* heapText = allocate(vm, length + 1);

  ObjString* string = allocate(vm, sizeof(ObjString));
  initObj(vm, &string->obj, OBJ_STRING);
  string->value = heapText;

  // Copy the string (if given one).
  if (text != NULL)
  {
    strncpy(heapText, text, length);
    heapText[length] = '\0';
  }

  return OBJ_VAL(string);
}
Exemplo n.º 20
0
/*
 * GetNextProcess
 * NB - callers must continue to call this function until it returns FALSE
 */
BOOL GetNextProcess( ProcList *info, ProcPlace *place, BOOL first ) {

    PERF_COUNTER_DEFINITION     *counter;
    BOOL                        error;

    error = FALSE;
    if( first ) {
        beginRead( FALSE );
        initObj( &regData, &processObject, N_PROCESS );
        if( processObject == NULL ) error = TRUE;
        if( !error ) {
            place->index = 0;
            place->obj = processObject;
            place->inst = getFirstInstance( processObject );
        }
    } else {
        place->index ++;
        if( place->index >= processObject->NumInstances ) {
            endRead( FALSE );
            return( FALSE );
        }
        place->inst = getNextInstance( place->inst );
    }
    if( place->inst == NULL ) error = TRUE;
    if( !error ) {
        counter = findCounter( place->obj, N_PROCID );
        if( counter == NULL ) error = TRUE;
    }
    if( !error ) {
        info->pid = getCounterDWORD( place->inst, counter );
        counter = findCounter( place->obj, N_BASE_PRIORITY );
        if( counter == NULL ) error = TRUE;
    }
    if( !error ) {
        info->priority = getCounterDWORD( place->inst, counter );
        wsprintf( info->name, "%ls",
                  (char *)( place->inst ) + place->inst->NameOffset );
    } else {
        endRead( FALSE );
    }
    return( !error );
}
Exemplo n.º 21
0
/*
 * GetProcessInfo
 */
BOOL GetProcessInfo( DWORD pid, ProcStats *info ) {

    DWORD                       i;
    PERF_COUNTER_DEFINITION     *counter;
    PERF_INSTANCE_DEFINITION    *inst;
    DWORD                       curpid;
    BOOL                        error;

    beginRead( FALSE );
    error = FALSE;
    initObj( &regData, &processObject, N_PROCESS );
    if( processObject == NULL ) error = TRUE;
    if( !error ) {
        counter = findCounter( processObject, N_PROCID );
        if( counter == NULL ) error = TRUE;
    }
    if( !error ) {
        inst = getFirstInstance( processObject );
        for( i=0; i < processObject->NumInstances; i++ ) {
            if( inst == NULL ) {
                error = TRUE;
                break;
            }
            curpid = getCounterDWORD( inst, counter );
            if( curpid == pid ) break;
            inst = getNextInstance( inst );
        }
    }
    if( !error && curpid == pid && info != NULL ) {
        info->pid = curpid;
        counter = findCounter( processObject, N_BASE_PRIORITY );
        if( counter == NULL ) {
            error = TRUE;
        } else {
            info->priority = getCounterDWORD( inst, counter );
            wsprintf( info->name, "%ls",
                      (char *)inst + inst->NameOffset );
        }
    }
    endRead( FALSE );
    return( !error && curpid == pid );
}
Exemplo n.º 22
0
Arquivo: obj.c Projeto: chamun/CGII
int
openObj (char *filename, objObj * obj)
{
	nameIndex *mtlIndex;
	nameIndex *texIndex;

	FILE *obj_fp = NULL;
	FILE *mtl_fp = NULL;

	mtlIndex = NULL;
	texIndex = NULL;

	obj->nbVertex = 0;
	obj->nbNormal = 0;
	obj->nbTexcoord = 0;
	obj->nbFace = 0;
	obj->nbMaterial = 0;

	obj->vertexList = NULL;
	obj->normalList = NULL;
	obj->texcoordList = NULL;
	obj->faceList = NULL;
	obj->materialList = NULL;



	if (initObj (filename, obj, &obj_fp, &mtl_fp, &mtlIndex, &texIndex))
		return cleanBeforeExit (1, obj, obj_fp, mtl_fp, mtlIndex,
					texIndex);

	if (readMtl (mtl_fp, *obj, mtlIndex, texIndex))
		return cleanBeforeExit (1, obj, obj_fp, mtl_fp, mtlIndex,
					texIndex);

	if (readObj (obj_fp, *obj, mtlIndex))
		return cleanBeforeExit (1, obj, obj_fp, mtl_fp, mtlIndex,
					texIndex);


	return cleanBeforeExit (0, obj, obj_fp, mtl_fp, mtlIndex, texIndex);
}
Exemplo n.º 23
0
Object *Object::initStream(Stream *streamA) {
  initObj(objStream);
  stream = streamA;
  return this;
}
Exemplo n.º 24
0
/*
 * GetImageMemInfo
 */
BOOL GetImageMemInfo( DWORD procid, char *imagename, MemByType *imageinfo ) {

    DWORD                       index;
    DWORD                       i;
    BOOL                        ret;
    char                        buf[ _MAX_PATH ];
    PERF_COUNTER_DEFINITION     *counter;
    PERF_INSTANCE_DEFINITION    *inst;

    ret = FALSE;
    beginRead( FALSE );
    beginRead( TRUE );

    initObj( &costlyData, &imageObject, N_IMAGE );
    initObj( &regData, &processObject, N_PROCESS );
    if( imageObject == NULL || processObject == NULL ) goto GETIMAGEMEM_ERROR;

    inst = getFirstInstance( imageObject );
    if( !getProcessIndex( procid, &index ) ) goto GETIMAGEMEM_ERROR;

    for( i=0; i < imageObject->NumInstances; i += 1 ) {
        if( inst == NULL ) goto GETIMAGEMEM_ERROR;

        if( inst->ParentObjectInstance == index ) {
            wsprintf( buf, "%ls", (char *)inst + inst->NameOffset );
            if( !strcmp( buf, imagename ) ) {
                counter = findCounter( imageObject, N_NO_ACCESS );
                if( counter == NULL ) goto GETIMAGEMEM_ERROR;
                imageinfo->noaccess = getCounterDWORD( inst, counter );

                counter = findCounter( imageObject, N_READ_ONLY );
                if( counter == NULL ) goto GETIMAGEMEM_ERROR;
                imageinfo->read = getCounterDWORD( inst, counter );

                counter = findCounter( imageObject, N_READ_WRITE );
                if( counter == NULL ) goto GETIMAGEMEM_ERROR;
                imageinfo->write = getCounterDWORD( inst, counter );

                counter = findCounter( imageObject, N_WRITE_COPY );
                if( counter == NULL ) goto GETIMAGEMEM_ERROR;
                imageinfo->copy = getCounterDWORD( inst, counter );

                counter = findCounter( imageObject, N_EXEC );
                if( counter == NULL ) goto GETIMAGEMEM_ERROR;
                imageinfo->exec = getCounterDWORD( inst, counter );

                counter = findCounter( imageObject, N_EXEC_READ );
                if( counter == NULL ) goto GETIMAGEMEM_ERROR;
                imageinfo->execread = getCounterDWORD( inst, counter );

                counter = findCounter( imageObject, N_EXEC_WRITE );
                if( counter == NULL ) goto GETIMAGEMEM_ERROR;
                imageinfo->execwrite = getCounterDWORD( inst, counter );

                counter = findCounter( imageObject, N_EXEC_COPY );
                if( counter == NULL ) goto GETIMAGEMEM_ERROR;
                imageinfo->execcopy = getCounterDWORD( inst, counter );

                imageinfo->tot = imageinfo->noaccess + imageinfo->read
                            + imageinfo->write + imageinfo->copy
                            + imageinfo->exec + imageinfo->execread
                            + imageinfo->execwrite + imageinfo->execcopy;
                ret = TRUE;
                break;
            }
        }
        inst = getNextInstance( inst );
    }
    endRead( TRUE );
    endRead( FALSE );
    return( ret);

GETIMAGEMEM_ERROR:
    endRead( TRUE );
    endRead( FALSE );
    return( FALSE );
}
Exemplo n.º 25
0
/*
 *  ======== Timer_Instance_init ========
 * 1. Select timer based on id
 * 2. Mark timer as in use
 * 3. Save timer handle if necessary (needed by TimestampProvider on 64).
 * 4. Init obj using params
 * 5. Create Hwi if tickFxn !=NULL
 * 6. Timer_init()
 * 7. Timer configuration (wrt emulation, external frequency etc)
 * 8. Timer_setPeriod()
 * 9. Timer_start()
 */
Int Timer_Instance_init(Timer_Object *obj, Int id, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb)
{
    UInt key;
    Int i, status;
    Hwi_Params hwiParams;
    UInt tempId = 0xffff;

    /* make sure id is not greater than number of 32-bit timer devices */
    if (id >= Timer_numTimerDevices ) {
        if (id != Timer_ANY) {
            Error_raise(eb, Timer_E_invalidTimer, id, 0);
            return (1);
        }
    }

    key = Hwi_disable();
    if (id == Timer_ANY) {
        for (i = 0; i < Timer_numTimerDevices; i++) {
            if ((Timer_anyMask & (1 << i)) &&
                (Timer_module->availMask & (1 << i))) {
                Timer_module->availMask &= ~(1 << i);
                tempId = i;
                break;
            }
        }
    }
    else if (Timer_module->availMask & (1 << id)) {
        Timer_module->availMask &= ~(1 << id);
        tempId = id;
    }

    Hwi_restore(key);

    obj->staticInst = FALSE;

    if (tempId == 0xffff) {
        Error_raise(eb, Timer_E_notAvailable, id, 0);
        return (2);
    }
    else {
        obj->id = tempId;
    }
    
    Timer_module->handles[obj->id] = obj;

    /* initialize the timer state object */
    initObj(obj, tickFxn, params);

    /* create the Hwi object if function is specified */
    if (obj->tickFxn != NULL) {
        if (params->hwiParams) {
            Hwi_Params_copy(&hwiParams, params->hwiParams);
        }
        else {
            Hwi_Params_init(&hwiParams);
        }

        hwiParams.eventId = Timer_module->device[obj->id].eventId;

        hwiParams.arg = (UArg)obj;
        obj->hwi = Hwi_create(obj->intNum, Timer_stub, &hwiParams, eb);

        if (obj->hwi == NULL) {
            return (4);
        }
    }
    else {
        obj->hwi = NULL;
    }

    status = postInit(obj, eb);

    if (status) {
        return (status);
    }

    if (obj->startMode == Timer_StartMode_AUTO) {
        Timer_start(obj);
    }

    return (0);
}
Exemplo n.º 26
0
int main(int argc, char * argv[]) {
   int rank = 0;
   PV_Init initObj(&argc, &argv, false/*do not allow unrecognized arguments*/);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   char const * paramFile1 = "input/CheckpointParameters1.params";
   char const * paramFile2 = "input/CheckpointParameters2.params";
   int status = PV_SUCCESS;
   if (initObj.getParamsFile()!=NULL) {
      if (rank==0) {
         pvErrorNoExit().printf("%s should be run without the params file argument.\n", initObj.getProgramName());
      }
      status = PV_FAILURE;
   }
   if (initObj.getCheckpointReadDir()!=NULL) {
      if (rank==0) {
         pvErrorNoExit().printf("%s should be run without the checkpoint directory argument.\n", argv[0]);
      }
      status = PV_FAILURE;
   }
   if (initObj.getRestartFlag()) {
      if (rank==0) {
         pvErrorNoExit().printf("%s should be run without the restart flag.\n", argv[0]);
      }
      status = PV_FAILURE;
   }
   if (status != PV_SUCCESS) {
      if (rank==0) {
         pvErrorNoExit().printf("This test uses two hard-coded params files, %s and %s. The second run is started from a checkpoint from the first run, and the results of the two runs are compared.\n",
               paramFile1, paramFile2);
      }
      MPI_Barrier(MPI_COMM_WORLD);
      exit(EXIT_FAILURE);
   }

   if (rank==0) {
      char const * rmcommand = "rm -rf checkpoints1 checkpoints2 output";
      status = system(rmcommand);
      if (status != 0) {
         pvError().printf("deleting old checkpoints and output directories failed: \"%s\" returned %d\n", rmcommand, status);
      }
   }

   initObj.registerKeyword("CPTestInputLayer", createCPTestInputLayer);
   initObj.registerKeyword("VaryingHyPerConn", createVaryingHyPerConn);
 
   initObj.setMPIConfiguration(0/*numRows unspecified*/, 0/*numColumns unspecified*/, 2/*batchWidth*/);
   initObj.setParams(paramFile1);

   status = rebuildandrun(&initObj);
   if( status != PV_SUCCESS ) {
      pvError().printf("%s: rank %d running with params file %s returned error %d.\n", initObj.getProgramName(), rank, paramFile1, status);
   }

   initObj.setParams(paramFile2);
   initObj.setCheckpointReadDir("checkpoints1/batchsweep_00/Checkpoint12:checkpoints1/batchsweep_01/Checkpoint12");

   status = rebuildandrun(&initObj);
   if( status != PV_SUCCESS ) {
      pvError().printf("%s: rank %d running with params file %s returned error %d.\n", initObj.getProgramName(), rank, paramFile2, status);
   }

   return status==PV_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
}
Exemplo n.º 27
0
/*
 * GetMemInfo
 */
BOOL GetMemInfo( DWORD procid, MemInfo *info ) {

    PERF_COUNTER_DEFINITION     *counter;
    PERF_INSTANCE_DEFINITION    *inst;
    DWORD                       curpid;
    DWORD                       i;

    beginRead( TRUE );
    initObj( &costlyData, &procAddrObject, N_PROCESS_ADDR_SPACE );
    if( procAddrObject == NULL ) {
        info->modlist = NULL;
        info->modcnt = 0;
        goto GETMEMINFO_ERROR;
    }

    info->modlist = GetModuleList( procid, &info->modcnt );
    if( info->modlist == NULL ) goto GETMEMINFO_ERROR;

    counter = findCounter( procAddrObject, N_PROCID );
    if( counter == NULL ) goto GETMEMINFO_ERROR;

    inst = getFirstInstance( procAddrObject );
    for( i=0; ; i++ ) {
        if( i >= procAddrObject->NumInstances || inst == NULL ) {
            goto GETMEMINFO_ERROR;
        }
        curpid = getCounterDWORD( inst, counter );
        if( curpid == procid ) break;
        inst = getNextInstance( inst );
    }

    counter = findCounter( procAddrObject, N_MAP_SPACE_NO_ACC );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->mapped.noaccess = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_MAP_SPACE_READ );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->mapped.read = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_MAP_SPACE_WRITE );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->mapped.write = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_MAP_SPACE_COPY );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->mapped.copy = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_MAP_SPACE_EXEC );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->mapped.exec = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_MAP_SPACE_EXECREAD );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->mapped.execread = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_MAP_SPACE_EXECWRITE );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->mapped.execwrite = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_MAP_SPACE_EXECCOPY );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->mapped.execcopy = getCounterDWORD( inst, counter );

    info->mapped.tot = info->mapped.noaccess + info->mapped.read
                        + info->mapped.write + info->mapped.copy
                        + info->mapped.exec + info->mapped.execread
                        + info->mapped.execwrite + info->mapped.execcopy;


    counter = findCounter( procAddrObject, N_RES_SPACE_NO_ACC );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->res.noaccess = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_RES_SPACE_READ );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->res.read = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_RES_SPACE_WRITE );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->res.write = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_RES_SPACE_COPY );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->res.copy = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_RES_SPACE_EXEC );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->res.exec = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_RES_SPACE_EXECREAD );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->res.execread = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_RES_SPACE_EXECWRITE );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->res.execwrite = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_RES_SPACE_EXECCOPY );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->res.execcopy = getCounterDWORD( inst, counter );

    info->res.tot = info->res.noaccess + info->res.read
                    + info->res.write + info->res.copy
                    + info->res.exec + info->res.execread
                    + info->res.execwrite + info->res.execcopy;


    counter = findCounter( procAddrObject, N_IMAGE_SPACE_NO_ACC );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->image.noaccess = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_IMAGE_SPACE_READ );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->image.read = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_IMAGE_SPACE_WRITE );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->image.write = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_IMAGE_SPACE_COPY );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->image.copy = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_IMAGE_SPACE_EXEC );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->image.exec = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_IMAGE_SPACE_EXECREAD );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->image.execread = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_IMAGE_SPACE_EXECWRITE );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->image.execwrite = getCounterDWORD( inst, counter );

    counter = findCounter( procAddrObject, N_IMAGE_SPACE_EXECCOPY );
    if( counter == NULL ) goto GETMEMINFO_ERROR;
    info->image.execcopy = getCounterDWORD( inst, counter );

    info->image.tot = info->image.noaccess + info->image.read
                    + info->image.write + info->image.copy
                    + info->image.exec + info->image.execread
                    + info->image.execwrite + info->image.execcopy;

    endRead( TRUE );
    return( TRUE );

GETMEMINFO_ERROR:
    FreeModuleList( info->modlist, info->modcnt );
    endRead( TRUE );
    return( FALSE );
}
Exemplo n.º 28
0
    inline void ImplicitCapillarity<GI, RP, BC, IP>::init(const Opm::parameter::ParameterGroup& param,
                                                          const GI& g, const RP& r, const BC& b)
    {
	init(param);
	initObj(g, r, b);
    }
Exemplo n.º 29
0
GameTools::GameTools()
{
    initObj();
}
Exemplo n.º 30
0
void base::FrameAnimatedNode::initComponent(NewtonWorld *_nWorld, irr::scene::ISceneManager *__sceneManager, int __id){
	initObj(__sceneManager, _nWorld, this, __id);

	_indexMoviment = 0;
}