/usr/include/libmesh/threads_allocators.h is in libmesh-dev 0.7.1-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | // $Id: threads_allocators.h 3874 2010-07-02 21:57:26Z roystgnr $
// The libMesh Finite Element Library.
// Copyright (C) 2002-2008 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef __threads_allocators_h__
#define __threads_allocators_h__
// System includes
#include <memory> // for std::allocator
// Local includes
#include "libmesh_config.h"
#include "threads.h"
// Threading building blocks includes
#ifdef LIBMESH_HAVE_TBB_API
# include "tbb/scalable_allocator.h"
#endif
namespace libMesh
{
/**
* The Threads namespace is for wrapper functions
* for common general multithreading algorithms and tasks.
*/
namespace Threads
{
#ifdef LIBMESH_HAVE_TBB_API
//-------------------------------------------------------------------
/**
* Scalable allocator to be used in multithreaded code chunks which
* allocate a lot of dynamic memory. This allocator can be faster
* than the std::allocator when there are multiple threads.
*/
template <typename T>
class scalable_allocator : public tbb::scalable_allocator<T>
{
public:
typedef T* pointer;
typedef const T* const_pointer;
// typedef T& reference; // Intel 7.1 tries to instantiate an allocator<void>,
// typedef const T& const_reference; // so we can't typedef a reference to void.
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
template<typename U>
struct rebind
{
typedef scalable_allocator<U> other;
};
scalable_allocator () :
tbb::scalable_allocator<T>() {}
scalable_allocator (const scalable_allocator &a) :
tbb::scalable_allocator<T>(a) {}
template<typename U>
scalable_allocator(const scalable_allocator<U> &a) :
tbb::scalable_allocator<T>(a) {}
};
#else //LIBMESH_HAVE_TBB_API
//-------------------------------------------------------------------
/**
* Just use std::allocator when the Threading Building Blocks is absent.
*/
template <typename T>
class scalable_allocator : public std::allocator<T>
{
public:
typedef T* pointer;
typedef const T* const_pointer;
// typedef T& reference; // Intel 7.1 tries to instantiate an allocator<void>,
// typedef const T& const_reference; // so we can't typedef a reference to void.
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
template<typename U>
struct rebind
{
typedef scalable_allocator<U> other;
};
scalable_allocator () :
std::allocator<T>() {}
scalable_allocator (const scalable_allocator &a) :
std::allocator<T>(a) {}
template<typename U>
scalable_allocator(const scalable_allocator<U> &a) :
std::allocator<T>(a) {}
};
#endif // #ifdef LIBMESH_HAVE_TBB_API
} // namespace Threads
} // namespace libMesh
#endif // #define __threads_allocators_h__
|