Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Tbb scalable allocator for containers #121

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 torch.cuda.is_available() 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