Skip to content

Commit 8df4262

Browse files
committed
use exclusive scan direct sums for remainigs
1 parent 128d407 commit 8df4262

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

frontend/_app_.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,7 @@ def clear_cache(self) -> "App":
179179
shutil.rmtree(item_path)
180180
else:
181181
os.remove(item_path)
182+
open3d_data_path = os.path.expanduser(os.path.join("~", "open3d_data"))
183+
if os.path.exists(os.path.expanduser(open3d_data_path)):
184+
shutil.rmtree(open3d_data_path)
182185
return self

frontend/_mesh_.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66
from typing import Optional
77
import os
8+
import time
89

910

1011
class MeshManager:
@@ -426,12 +427,27 @@ def preset(self, name: str) -> "TriMesh":
426427
import open3d as o3d
427428

428429
mesh = None
429-
if name == "armadillo":
430-
mesh = o3d.data.ArmadilloMesh()
431-
elif name == "knot":
432-
mesh = o3d.data.KnotMesh()
433-
elif name == "bunny":
434-
mesh = o3d.data.BunnyMesh()
430+
num_try, max_try, success, wait_time = 0, 5, False, 3
431+
while num_try < max_try:
432+
try:
433+
if name == "armadillo":
434+
mesh = o3d.data.ArmadilloMesh()
435+
elif name == "knot":
436+
mesh = o3d.data.KnotMesh()
437+
elif name == "bunny":
438+
mesh = o3d.data.BunnyMesh()
439+
success = True
440+
break
441+
except Exception as e:
442+
num_try += 1
443+
print(
444+
f"Mesh {name} could not be downloaded: {e}. Retrying... in {wait_time} seconds"
445+
)
446+
time.sleep(wait_time)
447+
448+
if not success:
449+
raise Exception(f"Mesh {name} could not be downloaded")
450+
435451
if mesh is not None:
436452
mesh = o3d.io.read_triangle_mesh(mesh.path)
437453
vert = np.asarray(mesh.vertices)

src/cpp/csrmat/csrmat.cu

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -308,23 +308,14 @@ void DynCSRMat::finalize() {
308308
DISPATCH_START(rows.size)
309309
[rows] __device__(unsigned i) mutable { rows[i].finalize(); } DISPATCH_END;
310310
assert(check());
311-
unsigned num_fixed_nnz = 0;
312311

313312
Vec<unsigned> fixed_row_offsets = this->fixed_row_offsets;
314313
DISPATCH_START(nrow)
315314
[fixed_row_offsets, rows] __device__(unsigned i) mutable {
316315
fixed_row_offsets[i] = rows[i].head;
317316
} DISPATCH_END;
318317

319-
unsigned tmp0, tmp1;
320-
CUDA_HANDLE_ERROR(cudaMemcpy(&tmp0, fixed_row_offsets.data + nrow - 1,
321-
sizeof(unsigned), cudaMemcpyDeviceToHost));
322-
323-
exclusive_scan(fixed_row_offsets.data, nrow);
324-
CUDA_HANDLE_ERROR(cudaMemcpy(&tmp1, fixed_row_offsets.data + nrow - 1,
325-
sizeof(unsigned), cudaMemcpyDeviceToHost));
326-
327-
num_fixed_nnz = tmp0 + tmp1;
318+
unsigned num_fixed_nnz = exclusive_scan(fixed_row_offsets.data, nrow);
328319
if (num_fixed_nnz > max_nnz) {
329320
printf("num_fixed_nnz: %u, max_nnz: %u\n", num_fixed_nnz, max_nnz);
330321
assert(false);
@@ -348,14 +339,7 @@ void DynCSRMat::finalize() {
348339
}
349340
} DISPATCH_END;
350341

351-
CUDA_HANDLE_ERROR(cudaMemcpy(&tmp0, ref_index_offsets.data + nrow - 1,
352-
sizeof(unsigned), cudaMemcpyDeviceToHost));
353-
354-
exclusive_scan(ref_index_offsets.data, nrow);
355-
CUDA_HANDLE_ERROR(cudaMemcpy(&tmp1, ref_index_offsets.data + nrow - 1,
356-
sizeof(unsigned), cudaMemcpyDeviceToHost));
357-
358-
unsigned num_nnz = tmp0 + tmp1;
342+
unsigned num_nnz = exclusive_scan(ref_index_offsets.data, nrow);
359343
if (num_nnz >= max_nnz) {
360344
printf("transpose num_nnz %u, max_nnz: %u\n", num_nnz, max_nnz);
361345
assert(false);

0 commit comments

Comments
 (0)