From cd1d5b1794daedbb936b1e118696a3909a3200b2 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Thu, 11 May 2023 13:19:51 +0200 Subject: [PATCH] Use the new registry and mapper API of Legate (#202) See https://github.com/nv-legate/legate.core/pull/675 and https://github.com/nv-legate/legate.core/pull/676 Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/kvikio/pull/202 --- legate/cpp/legate_kvikio.cpp | 4 ++-- legate/cpp/legate_mapping.cpp | 14 ++++---------- legate/cpp/legate_mapping.hpp | 6 ------ legate/cpp/tile_io.cpp | 2 +- legate/legate_kvikio/library_description.py | 9 +-------- 5 files changed, 8 insertions(+), 27 deletions(-) diff --git a/legate/cpp/legate_kvikio.cpp b/legate/cpp/legate_kvikio.cpp index f37cd25bab..4899fdece4 100644 --- a/legate/cpp/legate_kvikio.cpp +++ b/legate/cpp/legate_kvikio.cpp @@ -32,7 +32,7 @@ namespace legate_kvikio { * @brief Functor converting Legate type code to size */ struct elem_size_fn { - template + template size_t operator()() { return sizeof(legate::legate_type_of); @@ -45,7 +45,7 @@ struct elem_size_fn { * @param code Legate type code * @return The number of bytes */ -size_t sizeof_legate_type_code(legate::LegateTypeCode code) +size_t sizeof_legate_type_code(legate::Type::Code code) { return legate::type_dispatch(code, elem_size_fn{}); } diff --git a/legate/cpp/legate_mapping.cpp b/legate/cpp/legate_mapping.cpp index c424c03b1b..75ed18e128 100644 --- a/legate/cpp/legate_mapping.cpp +++ b/legate/cpp/legate_mapping.cpp @@ -22,7 +22,7 @@ namespace legate_kvikio { -class Mapper : public legate::mapping::LegateMapper { +class Mapper : public legate::mapping::Mapper { public: Mapper() {} @@ -80,16 +80,10 @@ Legion::Logger log_legate_kvikio(library_name); void registration_callback() { - legate::ResourceConfig config; - config.max_mappers = 1; - config.max_tasks = OP_NUM_TASK_IDS; - - legate::LibraryContext context(library_name, config); - + legate::ResourceConfig config = {.max_tasks = OP_NUM_TASK_IDS}; + auto context = legate::Runtime::get_runtime()->create_library( + library_name, config, std::make_unique()); Registry::get_registrar().register_all_tasks(context); - - // Now we can register our mapper with the runtime - context.register_mapper(std::make_unique(), 0); } } // namespace legate_kvikio diff --git a/legate/cpp/legate_mapping.hpp b/legate/cpp/legate_mapping.hpp index ef0d921337..2158cb0955 100644 --- a/legate/cpp/legate_mapping.hpp +++ b/legate/cpp/legate_mapping.hpp @@ -21,12 +21,6 @@ namespace legate_kvikio { struct Registry { - public: - template - static void record_variant(Args&&... args) - { - get_registrar().record_variant(std::forward(args)...); - } static legate::TaskRegistrar& get_registrar(); }; diff --git a/legate/cpp/tile_io.cpp b/legate/cpp/tile_io.cpp index 74d4e012d9..ddc9dc7ceb 100644 --- a/legate/cpp/tile_io.cpp +++ b/legate/cpp/tile_io.cpp @@ -74,7 +74,7 @@ std::filesystem::path get_file_path(const std::string& dirpath, */ template struct tile_read_write_fn { - template + template void operator()(legate::TaskContext& context, legate::Store& store) { using DTYPE = legate::legate_type_of; diff --git a/legate/legate_kvikio/library_description.py b/legate/legate_kvikio/library_description.py index 8bfd185aa6..67802e4e1d 100644 --- a/legate/legate_kvikio/library_description.py +++ b/legate/legate_kvikio/library_description.py @@ -5,7 +5,7 @@ from enum import IntEnum from typing import Any -from legate.core import Library, ResourceConfig, get_legate_runtime +from legate.core import Library, get_legate_runtime from legate_kvikio.install_info import header, libpath @@ -29,13 +29,6 @@ def get_c_header(self) -> str: def get_registration_callback(self) -> str: return "legate_kvikio_perform_registration" - def get_resource_configuration(self) -> ResourceConfig: - assert self.shared_object is not None - config = ResourceConfig() - config.max_mappers = 1 - config.max_tasks = self.cffi.OP_NUM_TASK_IDS - return config - def initialize(self, shared_object: Any) -> None: self.shared_object = shared_object