Beispiel #1
0
void ShaderNode_clear_links(ShaderNode _sn)
{
    ShaderObject exec_so = {NULL};
	/**
    if ( to_ptr(_sn->result_link) != NULL )
    {
        ShaderObject_delete(_sn->result_link);
        _sn->result_link = exec_so;
    }
**/
    for (euint32 i = 0; i < array_n(_sn->input_links); i++)
    {
        ShaderObject so = array_safe_get(_sn->input_links, i);
        if ( to_ptr(so) != NULL )
            ShaderObject_delete(so);
    }
    array_delete(_sn->input_links);
    _sn->input_links = array_new(ShaderObject, 5, exec_so);

    for (euint32 i = 0; i < array_n(_sn->output_links); i++)
    {
        ShaderObject so = array_safe_get(_sn->output_links, i);
        if ( to_ptr(so) != NULL )
            ShaderObject_delete(so);
    }
    array_delete(_sn->output_links);
    _sn->output_links = array_new(ShaderObject, 5, exec_so);
}
Beispiel #2
0
/* Interface. */
int atms_add_node(atms tms, const signed char assumption,
                  const signed char contradiction)
{
    atms_node node = (atms_node)malloc(sizeof(struct str_atms_node));

    if (NULL == node) {
        return -1;
    }
    memset(node, 0, sizeof(struct str_atms_node));

    node->index = tms->nodes->sz;
    node->assumption = assumption;
    node->contradiction = contradiction;

    node->consequences = array_new(NULL, NULL);

    node->label = trie_new((trie_node_destroy_func_t)array_free,
                           (trie_node_clone_func_t)array_copy);

    array_append(tms->nodes, node);

    if (assumption) {
/* The label of this node is a singleton environment with this node only. */
        array env = array_append(array_new(NULL, NULL), node);
        array key = get_environment_key(env);
        trie_add(node->label, key, env);
        array_free(key);
    }

    return node->index - 1;
}
Beispiel #3
0
void test_new() {
    value0 = array_new(array);
    mu_assert(value0 != NULL, "Failed to make a new element");

    value1 = array_new(array);
    mu_assert(value1 != NULL, "Failed to make a new element");
}
Beispiel #4
0
component_h add_input_handler_component(
    game_context_s *context,
    component_h parent)
{
    context = game_add_component(context, parent, release_component);

    component_subscribe(context, tick);

    input_handler_s *input_handler = malloc(sizeof(input_handler_s));
    game_set_component_data(context, input_handler);

    for(int i = 0; i < MAX_JOYSTICKS; i++)
    {
        input_handler->joysticks[i].joystick = i + 1;
        input_handler->joysticks[i].axes = array_new();
        input_handler->joysticks[i].buttons = array_new();
    }

    // only get input events when we explicitly ask with glfwPollEvents()
    glfwDisable(GLFW_AUTO_POLL_EVENTS);

    // set the callbacks. actually the callbacks might be called on setting
    // right now, particularly the window size one.
    target_context = context;
    glfwSetKeyCallback(key_callback);
    glfwSetWindowSizeCallback(window_size_callback);
    glfwSetWindowCloseCallback(window_close_callback);
    target_context = NULL;

    return game_get_self(context);
}
Beispiel #5
0
void mpiReduce_pickerV3(float       *resDataAbsMaxPaddedGlobal,
                        size_t      *resDataMaxIndPaddedGlobal,
                        size_t      resSize,
                        eXCorrMerge bAbs)
{
    resSizeMPI = resSize;

    MPI_Datatype mpiType;
    MPI_Type_contiguous((int) 2, MPI_FLOAT, &mpiType);
    MPI_Type_commit(&mpiType);

    float     *resDataGlobalNode = NULL;
    float     *resDataGlobalNodeReduce = NULL;

    array_new(resDataGlobalNode, 2*resSize);
    array_new(resDataGlobalNodeReduce, 2*resSize);

    memcpy(resDataGlobalNode,
           resDataAbsMaxPaddedGlobal,
           resSize*sizeof(float));
    mpiOp_array_typecast(resDataMaxIndPaddedGlobal,
                         resDataGlobalNode+resSize,
                         resSize);

    MPI_Op mpiOp;

    switch (bAbs) {
        case XCORR_MERGE_NEGATIVE:
            MPI_Op_create((MPI_User_function *) mpiOp_xcorrMergeResultGlobalV3Abs,
                          1,            // commutative
                          &mpiOp);
            break;
        case XCORR_MERGE_POSITIVE:
            MPI_Op_create((MPI_User_function *) mpiOp_xcorrMergeResultGlobalV3,
                          1,            // commutative
                          &mpiOp);
            break;
        default:
            ERROR("mpiReduce_pickerV3", "unsupported merging mode");
    }
    MPI_Reduce(resDataGlobalNode,
               resDataGlobalNodeReduce,
               (int) resSize,       // resSize elements of size 2*sizeof(float)
               mpiType,
               mpiOp,
               0,
               MPI_COMM_WORLD);
    MPI_Op_free(&mpiOp);

    memcpy(resDataAbsMaxPaddedGlobal,
           resDataGlobalNodeReduce,
           resSize*sizeof(float));
    mpiOp_array_typecast(resDataGlobalNodeReduce+resSize,
                         resDataMaxIndPaddedGlobal,
                         resSize);

    array_delete(resDataGlobalNode);
    array_delete(resDataGlobalNodeReduce);
    MPI_Type_free(&mpiType);
}
Beispiel #6
0
struct program_state *program_state_new(struct context *context, struct map *env)
{
    null_check(context);
    struct program_state *state = (struct program_state*)malloc(sizeof(struct program_state));
    state->named_variables = map_copy(env);
    state->all_variables = array_new();
    state->args = array_new();
    stack_push(context->program_stack, state);
    return state;
}
Beispiel #7
0
void init_quarks(void)
{
  size_t index;
  
  if (quarks)
    return;

  quarks = array_new((free_function_t)array_free);
  array_reserve(quarks, HASH_SIZE);
  for (index = 0; index < HASH_SIZE; ++index)
    array_append(quarks, array_new((free_function_t)free));

  quarks_index = array_new(NULL);
}
Beispiel #8
0
int ipp_add_tag( IPP *ipp, char tag_type, char *name,  void *value, short val_len, int set )
{
  struct _ipp_attr_seq *s;
  struct _ipp_attr_value *attr_value;
  IPP_ATTR *attr;
  ARRAY *vals;
  int i;

  if( tag_type&0xF0 ) { // Value
    s = array_get( ipp->seqs, array_len( ipp->seqs ) - 1 );

    for( i = 0; i < array_len( s->attr ); i++ ) {
      attr = array_get( s->attr, i );
      if( strcmp( attr->name, name ) == 0 ) {
        if( set ) {
          vals = attr->values;
        } else {
          array_free( attr->values );
          vals = attr->values = array_new();
        }
        break;
      }
    }

    if( i == array_len( s->attr ) ) {
      attr = calloc( 1, sizeof( IPP_ATTR ) );
      attr->name = strdup( name );
      vals = attr->values = array_new();
      array_add( s->attr, attr );
    }

    attr_value = malloc( sizeof( struct _ipp_attr_value ) );

    attr_value->type = tag_type;

    if( tag_type & (IPP_TAG_INTEGERS|IPP_TAG_OCTET_STRING) ) {  // Binary
      attr_value->value = malloc( val_len );
      memcpy( attr_value->value, value, val_len );
    } else if ( tag_type & IPP_TAG_CHAR_STRING ) { // CHARACTER-STRING
      attr_value->value = malloc( val_len + 1 ); // Terminating NUL
      memcpy( attr_value->value, value, val_len );
      ((char *)attr_value->value)[val_len] = '\0';
    }
    attr_value->len = val_len;
    array_add( vals, attr_value );
  } else {
    ipp_add_seq( ipp, tag_type );
  }
  return 1;
}
Beispiel #9
0
/**
 * Creates a new condition given a place and it's pre-event
 * @arg pl the image for the condition in the original net_t
 * @arg ev the single event in the preset of the condition
 * @return the newly created condition
 */
cond_t *nc_cond_new(place_t *pl, event_t *ev)
{
	struct cond_t *cond = (cond_t*)MYmalloc(sizeof(cond_t));
	cond->num = cond_last++;
	
	cond->pre_ev = ev;
	cond->origin = pl;
	
	cond->postset = array_new(0);
	cond->readarcs = array_new(0);
	
	cond->co_private = g_hash_table_new(NULL, NULL);
	
	return cond;
}
Beispiel #10
0
/* Data structures. */
atms atms_new()
{
    atms tms = (atms)malloc(sizeof(struct str_atms));
    if (NULL == tms) {
        return tms;
    }

    tms->nodes = array_new((array_element_destroy_func_t)atms_node_free, NULL);
    tms->justifications = array_new((array_element_destroy_func_t)atms_justification_free, NULL);

/* The "F" node is special. An environment of the "F" node is a "nogood". */
    atms_add_node(tms, 0, 1);

    return tms;
}
Beispiel #11
0
/*! \memberof array
 prepare cubic spline interpolation by calculating the a[i]'s */
array_t * array_cspline_prepare(array_t * s, array_t * h, array_t * f) {
  int k;
  // because the matrix is symmetic and the subdiagonals are never touched by the
  // calculation only two new vectors are needed: diag and b
  // all other values can be taken directly from the precalculated h vector

  // create and initialize matrix diagonal
  array_t * diag = array_new(s->length - 2);
  for (k = 0; k < diag->length; k++) { diag->data[k] = 2 * (h->data[k] + h->data[k + 1]); }

  // create and initialize value vector
  array_t * b = array_new(diag->length);
  for (k = 0; k < b->length; k++) {
    double f1 = f->data[k];
    double f2 = f->data[k + 1];
    double f3 = f->data[k + 2];
    double h1 = h->data[k];
    double h2 = h->data[k + 1];
    b->data[k] = 6 * ((f3 - f2) / h2 - (f2 - f1) / h1);
  }

  // calculate the new diagonal of the twodiagonal matrix
  for (k = 1 /* ! */; k < b->length; k++) {
    double lu = h->data[k];
    double dd = diag->data[k - 1];
    diag->data[k] += - lu * lu / dd;
    double tt = b->data[k - 1];
    b->data[k] += - lu * tt / dd;
  }

  // this will be the coefficients vector
  array_t * a = array_new(s->length);

  // natural cspline boundary condition
  a->data[0] = 0;
  a->data[a->length - 1] = 0;

  // calculate the rest of a[i]
  for (k = b->length - 1; k >= 0; k--) {
    a->data[k + 1] = (b->data[k] - h->data[k + 1] *  a->data[k + 2]) / diag->data[k];
  }

  // dispose of garbage
  free(diag);
  free(b);

  return a;
}
Beispiel #12
0
STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
    uint len;
    // Try to create array of exact len if initializer len is known
    mp_obj_t len_in = mp_obj_len_maybe(initializer);
    if (len_in == MP_OBJ_NULL) {
        len = 0;
    } else {
        len = MP_OBJ_SMALL_INT_VALUE(len_in);
    }

    mp_obj_array_t *array = array_new(typecode, len);

    mp_obj_t iterable = mp_getiter(initializer);
    mp_obj_t item;
    int i = 0;
    while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
        if (len == 0) {
            array_append(array, item);
        } else {
            mp_binary_set_val_array(typecode, array->items, i++, item);
        }
    }

    return array;
}
Beispiel #13
0
iridium_method(File, each_line) {
  object self = local(self);
  object filename = local(filename); // From self
  object fn = local(fn);
  object str = NULL;
  FILE * f = get_file(context, self);
  size_t file_size = file_length(context, f, filename);
  char * buffer = GC_MALLOC((file_size+1)*sizeof(char));
  assert(buffer);
  int nchars;
  char * line = NULL;

  while ((nchars = getline(&buffer, &file_size, f)) != -1) {
    // Remove the newline, if present
    if (buffer[nchars-1] == '\n') {
      buffer[nchars-1] = 0;
    }
    line = GC_MALLOC((nchars + 1) * sizeof(char));
    assert(line);
    strncpy(line, buffer, nchars);
    str = IR_STRING(line);
    calls(context, fn, array_push(array_new(), str));
  }
  return NIL;
}
int test(struct IridiumContext * context) {
  struct array * ary = array_new();

  assertEqual(array_get(ary, 0), NULL);

  return 0;
}
Beispiel #15
0
void test_array() {
    struct array* a = array_new(10);
    for (int i = 0; i < 10; ++i) {
        array_push_back(a, (void*)i);
    }
    array_debug_print(a);
    for (int i = 0; i < 10; ++i) {
        array_push_back(a, (void*)i);
    }
    for (int i = 0; i < 10; ++i) {
        array_push_back(a, (void*)i);
    }
    for (int i = 0; i < 10; ++i) {
        array_push_back(a, (void*)i);
    }
    for (int i = 0; i < 10; ++i) {
        array_push_back(a, (void*)i);
    }
    for (int i = 0; i < 10; ++i) {
        array_push_back(a, (void*)i);
    }
    for (int i = 0; i < 10; ++i) {
        array_push_back(a, (void*)i);
    }
    array_debug_print(a);
}
Beispiel #16
0
void
replace_word(array_t** stack, string_t word, string_t rule)
{
    string_t from;
    size_t   word_len = strlen(word), to_len, offset;

    from = strsep(&rule, RULE_SEPARATOR_STR);

    assert(0 != *rule); /* something to replace must be there */

    /*fprintf(stdout, "%s %s\n", word, from);*/

    if(0 != strcasecmp(word, from)) return;

    to_len = strlen(rule);

    if(to_len > word_len) { /* need to extend 'word' memory */

        if(ARR_FULL(*stack, to_len - word_len)) { /* re-alloc, adjust word */

            offset = PTR_DIFF(word, *stack);

            assert(NULL != (*stack = array_new(SMRZR_FALSE, 0, 0, *stack)));

            word = PTR_ADD(string_t, *stack, offset);
        }
    }

    strcpy(word, rule); /* replace */

    (*stack)->curr = PTR_ADD(elem_t, word, to_len + 1); /* adjust curr */
}
Beispiel #17
0
DEFINEFN
vinfo_t* PsycoFunction_New(PsycoObject* po, vinfo_t* fcode,
			   vinfo_t* fglobals, vinfo_t* fdefaults)
{
	vinfo_t* r;
	
	/* fdefaults contains potential arguments; mutable objects there
	   must be forced out of virtual-time right now */
	if (fdefaults != NULL && !psyco_forking(po, fdefaults->array))
		return NULL;

	/* Build a virtual function object */
	r = vinfo_new(VirtualTime_New(&psyco_computed_function));
	r->array = array_new(FUNC_TOTAL);
	r->array->items[iOB_TYPE] =
		vinfo_new(CompileTime_New((long)(&PyFunction_Type)));
	vinfo_incref(fcode);
	r->array->items[iFUNC_CODE] = fcode;
	vinfo_incref(fglobals);
	r->array->items[iFUNC_GLOBALS] = fglobals;
	if (fdefaults == NULL)
		fdefaults = psyco_vi_Zero();
	else
		vinfo_incref(fdefaults);
	r->array->items[iFUNC_DEFAULTS] = fdefaults;
	return r;
}
Beispiel #18
0
void physics_add(Entity ent)
{
    PhysicsInfo *info;

    if (entitypool_get(pool, ent))
        return; /* already has physics */

    transform_add(ent);

    info = entitypool_add(pool, ent);

    info->mass = 1.0;
    info->type = PB_DYNAMIC;

    /* create, init cpBody */
    info->body = cpSpaceAddBody(space, cpBodyNew(info->mass, 1.0));
    cpBodySetUserData(info->body, ent); /* for cpBody -> Entity mapping */
    cpBodySetPos(info->body, cpv_of_vec2(transform_get_position(ent)));
    cpBodySetAngle(info->body, transform_get_rotation(ent));
    info->last_dirty_count = transform_get_dirty_count(ent);

    /* initially no shapes */
    info->shapes = array_new(ShapeInfo);

    /* initialize last_pos/last_ang info for kinematic bodies */
    info->last_pos = cpBodyGetPos(info->body);
    info->last_ang = cpBodyGetAngle(info->body);

    info->collisions = NULL;
}
Beispiel #19
0
struct stack_s* stack_new(int num, int element_size)
{
    struct stack_s* ret = (struct stack_s*)malloc(sizeof(struct stack_s));

    if(NULL != ret)
    {
        memset(ret, 0, sizeof(*ret));

        ret->array = array_new(num, element_size);

        if(NULL != ret->array)
        {
            ret->element_num = num;
            ret->top = 0;
        }
        else
        {
            stack_delete(ret);
            ret = NULL;
        }
        
    }

    return ret;
}
static BREthereumMessage
provisionCreateMessageLES (BREthereumProvision *provisionMulti,
                           size_t messageContentLimit,
                           size_t messageIdBase,
                           size_t index) {
    uint64_t messageId = messageIdBase + index;
    switch (provisionMulti->type) {
        case PROVISION_BLOCK_HEADERS: {
            BREthereumProvisionHeaders *provision = &provisionMulti->u.headers;

            if (NULL == provision->headers) {
                array_new (provision->headers, provision->limit);
                array_set_count (provision->headers, provision->limit);
            }

            uint64_t start = provision->start + index * messageContentLimit;
            size_t  count = provision->limit - index * messageContentLimit;

            return (BREthereumMessage) {
                MESSAGE_LES,
                { .les = {
                    LES_MESSAGE_GET_BLOCK_HEADERS,
                    { .getBlockHeaders = {
                        messageId,
                        1, // use 'number'
                        { .number = start },
                        (uint32_t) minimum (count, messageContentLimit),
                        provision->skip,
                        ETHEREUM_BOOLEAN_IS_TRUE (provision->reverse)
                    }}}}
            };
        }
Beispiel #21
0
source *source_new()
{
  source *src = (source*)calloc(1,sizeof(source));
  src->scombs = array_new(sizeof(scomb*),0);
  list_push(&src->newimports,strdup("prelude"));
  return src;
}
Beispiel #22
0
void *
array_append(array_t *array, void const *element) {
    void *ptr = array_new(array);
    if (ptr != NULL)
        memcpy(ptr, element, array->e_size);
    return ptr;
}
Beispiel #23
0
TEST_F(ArrTest, testEnsure) {
  Foo *f = array_new(Foo, 1);
  array_hdr_t *hdr = array_hdr(f);
  Foo *tail = array_ensure_tail(&f, Foo);
  // Make sure Valgrind does not complain!
  tail->x = 0;
  tail->y = 0;

  Foo *middle = array_ensure_at(&f, 5, Foo);
  ASSERT_EQ(0, middle->x);
  ASSERT_EQ(0, middle->y);

  for (size_t ii = 0; ii < array_len(f); ++ii) {
    ASSERT_EQ(0, f[ii].x);
    ASSERT_EQ(0, f[ii].y);
  }

  // Try again with ensure_tail
  tail = array_ensure_tail(&f, Foo);
  f->x = 99;
  f->y = 990;
  tail->x = 100;
  tail->y = 200;

  // ensure_append
  Foo threeFoos[] = {{10, 11}, {20, 21}, {30, 31}};
  size_t prevlen = array_len(f);
  f = array_ensure_append(f, &threeFoos, 3, Foo);
  ASSERT_EQ(10, f[prevlen].x);
  ASSERT_EQ(20, f[prevlen + 1].x);
  ASSERT_EQ(30, f[prevlen + 2].x);
  array_free(f);
}
Beispiel #24
0
/*! \memberof array
 returns a vector of interpolated values of f for points in x */
array_t * array_cspline_dinterpolate(array_t * x, array_t * s, array_t * h, array_t * f, array_t * a)
{
  int k;
  array_t * p = array_new(x->length);
  for (k = 0; k < x->length; k++) {
    double z = x->data[k];
    int idx = array_getmaxindex(s, z);
    if (idx >= 0) {
      double s1 = s->data[idx];
      double s2 = s->data[idx + 1];
      double f1 = f->data[idx];
      double f2 = f->data[idx + 1];
      double a1 = a->data[idx];
      double a2 = a->data[idx + 1];
      double d1 = z - s1;
      double d2 = z - s2;
      double ih = h->data[idx];
      p->data[k] = (-(a2*(pow(ih,2) - 3*pow(d1,2))) + a1*(pow(ih,2) - 3*pow(d2,2)) - 6*f1 + 6*f2)/(6.*ih);
    } else {
      p->data[k] = 0;
    }
  }

  return p;
}
static value_t* ruby_to_value(VALUE v)
{
  switch (TYPE(v)) {
    case T_NIL:
      return value_new_void();
    case T_BIGNUM:
    case T_FIXNUM:
      return value_new_int32(NUM2INT(v));
    case T_TRUE:
      return value_new_boolean(true);
    case T_FALSE:
      return value_new_boolean(false);
    case T_FLOAT:
      return value_new_float32(NUM2DBL(v));
    case T_SYMBOL:
      return value_new_string(rb_id2name(SYM2ID(v)));
    case T_STRING:
      return value_new_string(StringValuePtr(v));
    case T_ARRAY: {
      /* process Array */
      value_t*array = array_new();
      int len = RARRAY(v)->len;
      int i;
      for(i=0;i<len;i++) {
          volatile VALUE item = RARRAY(v)->ptr[i];
          array_append(array, ruby_to_value(item));
      }
      return array;
    }
    default:
      /* raise exception */
      rb_raise(rb_eTypeError, "not valid value");
  }
}
Beispiel #26
0
void			free_(void *p)
{
	t_chunk		*c;
	t_mem		*m;

	if (!p)
		return ;
	g_malloc_memory = g_malloc_memory ? GMEM : array_new(sizeof(t_chunk), 0);
	while ((c = (t_chunk *)array_next(g_malloc_memory)))
	{
		if ((char *)p < c->start || (char *)p > c->start + c->size)
			continue ;
		while ((m = (t_mem *)array_next(c->mem)))
		{
			if ((char *)p < m->start || (char *)p > m->start + m->size)
				continue ;
			array_remove(c->mem, c->mem->it - 1);
			c->mem->it = 0;
			g_malloc_memory->it = 0;
			if (c->mem->size == 0)
				array_remove(g_malloc_memory, g_malloc_memory->it);
			return ;
		}
		c->mem->it = 0;
	}
	g_malloc_memory->it = 0;
	free__(p);
}
Beispiel #27
0
int main(void)
{
	t_array	*arr;

	arr = array_new(sizeof(int), 0);
	
	array_add(arr, (int[]) { 17 });
Beispiel #28
0
elem_t
array_search_or_alloc(array_t** array, const elem_t key, compfunc_t cf, bool_t* is_new)
{
    size_t      num_elems;
    elem_t      elem0, center, elem;
    int         lo, hi, mid;
    array_t   * a = *array;

    assert(SMRZR_TRUE == a->is_array && 0 != a->elem_sz);

    elem0 = PTR_ADD(elem_t, a, sizeof(array_t));

    num_elems = PTR_DIFF(a->curr, elem0) / a->elem_sz;

    if(!num_elems) {
        a->curr = PTR_ADD(elem_t, elem0, a->elem_sz);
        *is_new = SMRZR_TRUE;
        return(elem0);
    }

    lo = 0;
    hi = num_elems-1;

    while(lo <= hi) {

        mid = (lo + hi)/2;

        center = PTR_ADD(elem_t, elem0, mid * a->elem_sz);

        switch(cf(center, key)) {
            case SMRZR_EQ:
                *is_new = SMRZR_FALSE;
                return(center);
            case SMRZR_GT: hi = mid - 1; break;
            case SMRZR_LT: lo = mid + 1; break;
            default: assert(SMRZR_FALSE);
        }
    }

    /* insert just before lo */
    if(SMRZR_TRUE == ARR_FULL(a, a->elem_sz)) {
        if(NULL == (*array = array_new(a->is_array, a->elem_sz,
                                       2 * a->num_elems, a)))
            return(NULL);

        a = *array;

        elem0 = PTR_ADD(elem_t, a, sizeof(array_t));
    }

    elem = PTR_ADD(elem_t, elem0, lo * a->elem_sz);

    memmove(PTR_ADD(elem_t, elem, a->elem_sz), elem, PTR_DIFF(a->curr, elem));

    a->curr = PTR_ADD(elem_t, a->curr, a->elem_sz);

    *is_new = SMRZR_TRUE;

    return(elem);
}
Beispiel #29
0
static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode)
{
  unsigned *a;
  xbt_dynar_t data;
  xbt_parmap_t parmap;
  int i;
  double start_time, elapsed_time;

  printf("** mode = %-15s ", parmap_mode_name(mode));
  fflush(stdout);

  if (parmap_skip_mode(mode))
    return;

  array_new(&a, &data);

  i = 0;
  start_time = xbt_os_time();
  do {
    parmap = xbt_parmap_new(nthreads, mode);
    xbt_parmap_apply(parmap, fun_to_apply, data);
    xbt_parmap_destroy(parmap);
    elapsed_time = xbt_os_time() - start_time;
    i++;
  } while (elapsed_time < TIMEOUT);

  printf("ran %d times in %g seconds (%g/s)\n",
         i, elapsed_time, i / elapsed_time);

  xbt_dynar_free(&data);
  xbt_free(a);
}
Beispiel #30
0
/**
 * Creates an event for the unfolding
 */
event_t *nc_event_new(trans_t *tr, array_t *pre, array_t *read)
{
	event_t *ev = (event_t*)MYmalloc(sizeof(event_t));
	ev->num = event_last++;
	
	ev->origin = tr;
	ev->preset = pre;
	ev->readarcs = read;
	
	// Adds a new condition for each place in the postset:
	array_t *post = ev->postset = array_new(tr->postset_size);
	nodelist_t *ps = tr->postset;
	while (ps) {
		cond_t *cond = nc_cond_new(ps->node, ev);
		array_append(post, cond);
		ps = ps->next;
	}
	array_sort(post);
#ifdef __DEBUG__
	g_assert(array_ordered(post));
#endif

	ev->hist = g_hash_table_new(NULL, NULL);
	
	return ev;
}