-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] Create taichi_isolated_core that is free from pybind11
- Loading branch information
Showing
21 changed files
with
140 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "taichi/backends/cuda/detect_cuda.h" | ||
|
||
#if defined(TI_WITH_CUDA) | ||
#include "taichi/backends/cuda/cuda_driver.h" | ||
#endif | ||
|
||
namespace taichi { | ||
|
||
bool is_cuda_api_available() { | ||
#if defined(TI_WITH_CUDA) | ||
return lang::CUDADriver::get_instance_without_context().detected(); | ||
#else | ||
return false; | ||
#endif | ||
} | ||
|
||
} // namespace taichi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace taichi { | ||
bool is_cuda_api_available(); | ||
} // namespace taichi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "taichi/program/py_print_buffer.h" | ||
|
||
namespace taichi { | ||
|
||
PythonPrintBuffer py_cout; | ||
|
||
} // namespace taichi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
taichi/system/memory_usage_monitor.cpp → taichi/python/memory_usage_monitor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
taichi/system/memory_usage_monitor.h → taichi/python/memory_usage_monitor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#include "virtual_memory.h" | ||
#pragma once | ||
|
||
#include "taichi/system/virtual_memory.h" | ||
|
||
TI_NAMESPACE_BEGIN | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <csignal> | ||
|
||
#include "pybind11/pybind11.h" | ||
|
||
namespace taichi { | ||
|
||
namespace { | ||
|
||
// Translates and propagates a CPP exception to Python. | ||
// TODO(#2198): How can we glob all these global variables used as initializaers | ||
// into a single function? | ||
class ExceptionTranslationImpl { | ||
public: | ||
explicit ExceptionTranslationImpl() { | ||
pybind11::register_exception_translator([](std::exception_ptr p) { | ||
try { | ||
if (p) | ||
std::rethrow_exception(p); | ||
} catch (const std::string &e) { | ||
PyErr_SetString(PyExc_RuntimeError, e.c_str()); | ||
} catch (const std::exception &e) { | ||
PyErr_SetString(PyExc_RuntimeError, e.what()); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
ExceptionTranslationImpl _; | ||
|
||
} // namespace | ||
} // namespace taichi |
Oops, something went wrong.