Skip to content

Commit

Permalink
Tbb scalable allocator for containers
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmisko committed Sep 2, 2019
1 parent 1171aae commit 66682d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
this_dir = os.path.dirname(os.path.realpath(__file__))
torch_dir = os.path.dirname(torch.__file__)
conda_include_dir = '/'.join(torch_dir.split('/')[:-4]) + '/include'
conda_lib_dir = os.environ["CONDA_PREFIX"] + '/lib/'

extra = {'cxx': ['-std=c++11', '-fopenmp'], 'nvcc': ['-std=c++11', '-Xcompiler', '-fopenmp']}
extra_link = ['-ltbb', '-ltbbmalloc']

setup(
name='sparseconvnet',
Expand All @@ -29,13 +31,14 @@
CUDAExtension('sparseconvnet.SCN',
[
'sparseconvnet/SCN/cuda.cu', 'sparseconvnet/SCN/sparseconvnet_cuda.cpp', 'sparseconvnet/SCN/pybind.cpp'],
include_dirs=[conda_include_dir, this_dir+'/sparseconvnet/SCN/'],
include_dirs=[conda_include_dir, this_dir+'/sparseconvnet/SCN/', conda_lib_dir],
extra_compile_args=extra)
if torch.cuda.is_available() else
if False else
CppExtension('sparseconvnet.SCN',
['sparseconvnet/SCN/pybind.cpp', 'sparseconvnet/SCN/sparseconvnet_cpu.cpp'],
include_dirs=[conda_include_dir, this_dir+'/sparseconvnet/SCN/'],
extra_compile_args=extra['cxx'])],
extra_compile_args=extra['cxx'],
extra_link_args=extra_link)],
cmdclass={'build_ext': BuildExtension},
zip_safe=False,
)
9 changes: 5 additions & 4 deletions sparseconvnet/SCN/Metadata/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef Metadata_H
#define Metadata_H
#include "32bits.h"
#include "tbb/scalable_allocator.h"
#include <algorithm>
#include <array>
#include <cassert>
Expand All @@ -22,17 +23,17 @@
#include <vector>

template <Int dimension>
using SparseGridMap =
google::dense_hash_map<Point<dimension>, Int, IntArrayHash<dimension>,
std::equal_to<Point<dimension>>>;
using SparseGridMap = google::dense_hash_map<Point<dimension>, Int, IntArrayHash<dimension>,
std::equal_to<Point<dimension>>, tbb::scalable_allocator<std::pair<Point<dimension>, Int>>>;

template <Int dimension> class SparseGrid {
public:
Int ctr;
SparseGridMap<dimension> mp;
SparseGrid();
};
template <Int dimension> using SparseGrids = std::vector<SparseGrid<dimension>>;
using RuleBook = std::vector<std::vector<Int>>;
using RuleBook = std::vector<std::vector<Int, tbb::scalable_allocator<Int>>>;

template <Int dimension>
void addPointToSparseGridMapAndFeatures(SparseGridMap<dimension> &mp,
Expand Down

0 comments on commit 66682d1

Please sign in to comment.