Example #1
0
void swap(item *a, item *b)
{
	element tmp;
	tmp.type = b->value.type;
	AssignElement(&tmp, a->value);
	AssignElement(&a->value, b->value);
	AssignElement(&b->value, tmp);
}
Example #2
0
element MinValue(list l)
{
	element x = { BuildValue(head(l)), head(l).type };
	for (size_t i = 0; tail(l) != NULL; ++i)
	{
		if (cmp(x, (head(tail(l)))) > 0)
			AssignElement(&x, head(tail(l)));
		l = tail(l);
	}
	return x;
}
Example #3
0
element MaxValue(list l)
{
	element x = { BuildValue(head(l)), head(l).type };
	while (empty(tail(l)) == false)
	{
		if (cmp(x, (head(tail(l)))) < 0)
			AssignElement(&x, head(tail(l)));
		l = tail(l);
	}
	return x;
}
//! Test parallel access by iterators
void TestParallelFor( int nthread ) {
    typedef tbb::concurrent_vector<int> vector_t;
    vector_t v;
    v.resize(N);
    tbb::tick_count t0 = tbb::tick_count::now();
    REMARK("Calling parallel_for with %ld threads\n",long(nthread));
    tbb::parallel_for( v.range(10000), AssignElement(v.begin()) );
    tbb::tick_count t1 = tbb::tick_count::now();
    const vector_t& u = v;
    tbb::parallel_for( u.range(10000), CheckElement(u.begin()) );
    tbb::tick_count t2 = tbb::tick_count::now();
    REMARK("Time for parallel_for: assign time = %8.5f, check time = %8.5f\n",
               (t1-t0).seconds(),(t2-t1).seconds());
    for( long i=0; size_t(i)<v.size(); ++i )
        if( v[i]!=i )
            REPORT("ERROR for v[%ld]\n", i);
}