Skip to content

Commit

Permalink
Use the new registry and mapper API of Legate (#202)
Browse files Browse the repository at this point in the history
See nv-legate/legate#675 and nv-legate/legate#676

Authors:
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)

URL: #202
  • Loading branch information
madsbk authored May 11, 2023
1 parent d1daea8 commit cd1d5b1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 27 deletions.
4 changes: 2 additions & 2 deletions legate/cpp/legate_kvikio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace legate_kvikio {
* @brief Functor converting Legate type code to size
*/
struct elem_size_fn {
template <legate::LegateTypeCode DTYPE>
template <legate::Type::Code DTYPE>
size_t operator()()
{
return sizeof(legate::legate_type_of<DTYPE>);
Expand All @@ -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{});
}
Expand Down
14 changes: 4 additions & 10 deletions legate/cpp/legate_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace legate_kvikio {

class Mapper : public legate::mapping::LegateMapper {
class Mapper : public legate::mapping::Mapper {
public:
Mapper() {}

Expand Down Expand Up @@ -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<Mapper>());
Registry::get_registrar().register_all_tasks(context);

// Now we can register our mapper with the runtime
context.register_mapper(std::make_unique<Mapper>(), 0);
}

} // namespace legate_kvikio
Expand Down
6 changes: 0 additions & 6 deletions legate/cpp/legate_mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
namespace legate_kvikio {

struct Registry {
public:
template <typename... Args>
static void record_variant(Args&&... args)
{
get_registrar().record_variant(std::forward<Args>(args)...);
}
static legate::TaskRegistrar& get_registrar();
};

Expand Down
2 changes: 1 addition & 1 deletion legate/cpp/tile_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ std::filesystem::path get_file_path(const std::string& dirpath,
*/
template <bool IsReadOperation>
struct tile_read_write_fn {
template <legate::LegateTypeCode CODE, int32_t DIM>
template <legate::Type::Code CODE, int32_t DIM>
void operator()(legate::TaskContext& context, legate::Store& store)
{
using DTYPE = legate::legate_type_of<CODE>;
Expand Down
9 changes: 1 addition & 8 deletions legate/legate_kvikio/library_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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

Expand Down

0 comments on commit cd1d5b1

Please sign in to comment.