1
1
openmpi/opal/class/opal_fifo.c
Nathan Hjelm d1114ec17a Add opal_fifo_t class
This commit adds a new class: opal_fifo.h. The new class has atomic, non-atomic,
and opal_using_threads() conditoned routines. It should be used when first-in
first-out is required and should perform much better than using locks and an
opal_list_t. Like with opal_lifo_t there are two versions of the atomic
implementation: 128-bit compare-and-swap, and spin-locked. More implementations
can be added later (LL/SC comes to mind).

This commit also adds a unit test for the opal_fifo_t class. This test verifies
the fifo implementation when using multiple threads.
2014-12-04 15:30:02 -07:00

42 строки
1.5 KiB
C

/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2014 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/class/opal_fifo.h"
static void opal_fifo_construct (opal_fifo_t *fifo)
{
OBJ_CONSTRUCT(&fifo->opal_fifo_ghost, opal_list_item_t);
fifo->opal_fifo_ghost.opal_list_next = &fifo->opal_fifo_ghost;
/** used to protect against ABA problems when not using a 128-bit compare-and-set */
fifo->opal_fifo_ghost.item_free = 0;
fifo->opal_fifo_head.data.counter = 0;
fifo->opal_fifo_head.data.item = &fifo->opal_fifo_ghost;
fifo->opal_fifo_tail.data.counter = 0;
fifo->opal_fifo_tail.data.item = &fifo->opal_fifo_ghost;
}
OBJ_CLASS_INSTANCE(opal_fifo_t, opal_object_t, opal_fifo_construct, NULL);