Skip to content

Commit

Permalink
use the tools provided in the luisa name space
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomx32 committed Dec 7, 2024
1 parent 01e928b commit 31add72
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
26 changes: 14 additions & 12 deletions include/luisa/core/dynamic_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace luisa {

/**
* @brief Dynamic module loader
*
*
*/
class LC_CORE_API DynamicModule : concepts::Noncopyable {

Expand All @@ -29,7 +29,7 @@ class LC_CORE_API DynamicModule : concepts::Noncopyable {
void dispose() noexcept;
/**
* @brief Return function pointer of given name
*
*
* @tparam F function type
* @param name name of function
* @return pointer to function
Expand All @@ -42,17 +42,17 @@ class LC_CORE_API DynamicModule : concepts::Noncopyable {

/**
* @brief Return address of given name
*
*
* @param name
* @return void*
* @return void*
*/
[[nodiscard]] void *address(std::string_view name) const noexcept {
return dynamic_module_find_symbol(_handle, name);
}

/**
* @brief Invoke function
*
*
* @tparam F function type
* @tparam Args function args
* @param name name of function
Expand All @@ -67,12 +67,12 @@ class LC_CORE_API DynamicModule : concepts::Noncopyable {

/**
* @brief Apply function to each element
*
*
* @tparam F function type
* @tparam Tuple tuple type
* @param name name of function
* @param t tuple to be applied
* @return decltype(auto)
* @return decltype(auto)
*/
template<concepts::function F, typename Tuple>
decltype(auto) apply(std::string_view name, Tuple &&t) const noexcept {
Expand All @@ -81,15 +81,15 @@ class LC_CORE_API DynamicModule : concepts::Noncopyable {

/**
* @brief Add dynamic module search path
*
* @param path
*
* @param path
*/
static void add_search_path(const std::filesystem::path &path) noexcept;

/**
* @brief Remove dynamic module search path
*
* @param path
*
* @param path
*/
static void remove_search_path(const std::filesystem::path &path) noexcept;

Expand All @@ -108,7 +108,9 @@ class LC_CORE_API DynamicModule : concepts::Noncopyable {
* @return The module if successfully loaded, otherwise a nullopt
*/
[[nodiscard]] static DynamicModule load(
const std::filesystem::path &folder, std::string_view name) noexcept;
const luisa::filesystem::path &folder,
std::string_view name
) noexcept;
};

}// namespace luisa
2 changes: 1 addition & 1 deletion include/luisa/runtime/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LC_RUNTIME_API Context {
luisa::shared_ptr<detail::ContextImpl> _impl;

public:
explicit Context(luisa::shared_ptr<luisa::compute::detail::ContextImpl> impl) noexcept;
explicit Context(luisa::shared_ptr<detail::ContextImpl> impl) noexcept;
// program_path can be first arg from main entry
explicit Context(luisa::string_view program_path) noexcept;
explicit Context(const char *program_path) noexcept
Expand Down
4 changes: 2 additions & 2 deletions src/core/dynamic_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void DynamicModule::dispose() noexcept {
}

[[nodiscard]] static auto &dynamic_module_search_paths() noexcept {
static luisa::vector<std::pair<std::filesystem::path, size_t>> paths;
static luisa::vector<std::pair<luisa::filesystem::path, std::size_t>> paths;
return paths;
}

Expand Down Expand Up @@ -65,7 +65,7 @@ void DynamicModule::add_search_path(const luisa::filesystem::path &path) noexcep
auto &&cookies = dynamic_module_search_path_cookies();
cookies.emplace_back(AddDllDirectory(canonical_path.c_str()));
#endif
paths.emplace_back(std::move(canonical_path), 0u);
paths.emplace_back(std::move(canonical_path), 0);
}
}

Expand Down

0 comments on commit 31add72

Please sign in to comment.