Esempio n. 1
0
 void operator()(T& v, const T& value) const
 {
   if (value < v)
   {
     T probe = mt_readfe(v);
     if (value < v)
     {
       mt_write(v, value);
     }
     else
     {
       mt_write(v, probe);
     }
   }
 }
Esempio n. 2
0
  void operator()(edge_descriptor e)
  {
    int eid = get(eid_map, e);

    vertex_descriptor src = source(e, g);
    vertex_descriptor trg = target(e, g);
    int sid = get(vid_map, src);
    int tid = get(vid_map, trg);

    int same = (community[sid] == community[tid]);
    double diff = same - support[eid];
    double res = mt_readfe(result);

    mt_write(result, res + diff * diff);
  }
Esempio n. 3
0
inline double mt_incr(double& target, T inc)
{
#ifdef __MTA__
  double res = mt_readfe(target);
  mt_write(target, res + inc);
#elif _OPENMP
  double res;
  #pragma omp critical
  {
    res = target;
    target += inc;
  }
#elif USING_QTHREADS
  double res = qthread_dincr(&target, inc);
#else
  double res = target;
  target += inc;
#endif

  return res;
}
Esempio n. 4
0
int main(void)
{
	const size_t page_size = 1 << sim_nand.log2_page_size;
	struct dhara_map map;
	uint8_t page_buf[page_size];
	int write_seed = 0;
	int i;

	sim_reset();
	dhara_map_init(&map, &sim_nand, page_buf, GC_RATIO);
	dhara_map_resume(&map, NULL);
	printf("resumed, head = %d\n", map.journal.head);

	/* Write pages until we have just barely wrapped around, but not
	 * yet hit a checkpoint.
	 */
	for (i = 0; i < 200; i++)
		mt_write(&map, i, write_seed++);
	printf("written a little, head = %d\n", map.journal.head);

	for (i = 0; i < 200; i++)
		mt_write(&map, i, write_seed++);
	printf("written a little, head = %d\n", map.journal.head);
	for (i = 0; i < 200; i++)
		mt_write(&map, i, write_seed++);
	printf("written a little, head = %d\n", map.journal.head);
	for (i = 0; i < 79; i++)
		mt_write(&map, i, write_seed++);
	printf("written a little, head = %d\n", map.journal.head);
	assert(map.journal.head == 1); /* Required for this test */

	/* Now, see what happens on resume if we don't sync.
	 *
	 * Here's where a bug occured: the new epoch counter was not
	 * incremented when finding the next free user page, if that
	 * procedure required wrapping around the end of the chip from
	 * the last checkblock. From this point on, new pages written
	 * are potentially lost, because they will be wrongly identified
	 * as older than the pages coming physically later in the chip.
	 */
	printf("before resume: head = %d, tail = %d, epoch = %d\n",
		map.journal.head, map.journal.tail, map.journal.epoch);
	dhara_map_resume(&map, NULL);
	printf("resumed, head = %d, tail = %d, epoch = %d\n",
		map.journal.head, map.journal.tail, map.journal.epoch);

	for (i = 0; i < 2; i++)
		mt_write(&map, i, i + 10000);
	printf("written new data, head = %d\n", map.journal.head);
	dhara_map_sync(&map, NULL);

	/* Try another resume */
	printf("--------------------------------------------------------\n");
	printf("before resume: head = %d, tail = %d, epoch = %d\n",
		map.journal.head, map.journal.tail, map.journal.epoch);
	mt_assert(&map, 0, 10000);
	mt_assert(&map, 1, 10001);
	dhara_map_resume(&map, NULL);
	printf("resumed, head = %d, tail = %d, epoch = %d\n",
		map.journal.head, map.journal.tail, map.journal.epoch);
	mt_assert(&map, 0, 10000);
	mt_assert(&map, 1, 10001);

	return 0;
}