mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 22:30:35 +08:00
Multithread CPU naive mesh rasterization
Summary:
Threaded the for loop:
```
for (int yi = 0; yi < H; ++yi) {...}
```
in function `RasterizeMeshesNaiveCpu()`.
Chunk size is approx equal.
Reviewed By: bottler
Differential Revision: D40063604
fbshipit-source-id: 09150269405538119b0f1b029892179501421e68
This commit is contained in:
committed by
Facebook GitHub Bot
parent
37bd280d19
commit
6471893f59
@@ -35,7 +35,7 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
||||
self._test_barycentric_clipping(rasterize_meshes_python, device, bin_size=-1)
|
||||
self._test_back_face_culling(rasterize_meshes_python, device, bin_size=-1)
|
||||
|
||||
def test_simple_cpu_naive(self):
|
||||
def _test_simple_cpu_naive_instance(self):
|
||||
device = torch.device("cpu")
|
||||
self._simple_triangle_raster(rasterize_meshes, device, bin_size=0)
|
||||
self._simple_blurry_raster(rasterize_meshes, device, bin_size=0)
|
||||
@@ -43,6 +43,16 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
||||
self._test_perspective_correct(rasterize_meshes, device, bin_size=0)
|
||||
self._test_back_face_culling(rasterize_meshes, device, bin_size=0)
|
||||
|
||||
def test_simple_cpu_naive(self):
|
||||
n_threads = torch.get_num_threads()
|
||||
torch.set_num_threads(1) # single threaded
|
||||
self._test_simple_cpu_naive_instance()
|
||||
torch.set_num_threads(4) # even (divisible) number of threads
|
||||
self._test_simple_cpu_naive_instance()
|
||||
torch.set_num_threads(5) # odd (nondivisible) number of threads
|
||||
self._test_simple_cpu_naive_instance()
|
||||
torch.set_num_threads(n_threads)
|
||||
|
||||
def test_simple_cuda_naive(self):
|
||||
device = get_random_cuda_device()
|
||||
self._simple_triangle_raster(rasterize_meshes, device, bin_size=0)
|
||||
|
||||
Reference in New Issue
Block a user