Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configfile #197

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ if(Legion_USE_HWLOC)
)
endif()

#------------------------------------------------------------------------------#
# LuaJIT configuration
#------------------------------------------------------------------------------#
option(Legion_USE_LuaJIT "Use LuaJIT for config file" OFF)
if(Legion_USE_LuaJIT)
find_package(LuaJIT REQUIRED)
install(FILES ${Legion_SOURCE_DIR}/cmake/FindLuaJIT.cmake
DESTINATION lib/cmake/Legion
)
endif()

#------------------------------------------------------------------------------#
# GASNet configuration
#------------------------------------------------------------------------------#
Expand Down
70 changes: 70 additions & 0 deletions cmake/FindLuaJIT.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#------------------------------------------------------------------------------#
# Copyright 2016 Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#------------------------------------------------------------------------------#

find_path(LUA_INCLUDE_DIR luajit.h
HINTS
ENV LUAJIT
PATH_SUFFIXES include/luajit-2.0 include
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)

find_library(LUA_LIBRARY
NAMES luajit-5.1
HINTS
ENV LUAJIT
PATH_SUFFIXES lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
)

if(LUA_LIBRARY)
# include the math library for Unix
if(UNIX AND NOT APPLE)
find_library(LUA_MATH_LIBRARY m)
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
else()
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
endif()
endif()

if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
file(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" luajit_version_str REGEX "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT .+\"")

string(REGEX REPLACE "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${luajit_version_str}")
unset(luajit_version_str)
endif()

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUAJIT_VERSION_STRING)

mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)

13 changes: 13 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ else()
if(Legion_USE_GASNet)
list(APPEND LOW_RUNTIME_SRC activemsg.h activemsg.cc)
endif()
if(Legion_USE_LuaJIT)
list(APPEND LOW_RUNTIME_SRC realm/options.h realm/options.cc)
endif()
endif()
list(APPEND LOW_RUNTIME_SRC
accessor.h
Expand Down Expand Up @@ -162,6 +165,12 @@ if(Legion_USE_CUDA)
target_link_libraries(LowLevelRuntime PRIVATE ${CUDA_CUDA_LIBRARY})
endif()

if(Legion_USE_LuaJIT)
target_compile_definitions(LowLevelRuntime PUBLIC REALM_USE_LUAJIT)
target_include_directories(LowLevelRuntime PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(LowLevelRuntime PRIVATE ${LUA_LIBRARIES})
endif()

if(Legion_USE_SHARED_LOWLEVEL)
set_target_properties(LowLevelRuntime PROPERTIES OUTPUT_NAME sharedllr)
else()
Expand Down Expand Up @@ -248,6 +257,10 @@ target_include_directories(HighLevelRuntime
PRIVATE legion realm mappers
)

if(Legion_USE_LuaJIT)
target_include_directories(HighLevelRuntime PRIVATE ${LUA_INCLUDE_DIR})
endif()

install(TARGETS HighLevelRuntime EXPORT LegionTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
143 changes: 76 additions & 67 deletions runtime/legion/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "replay_mapper.h"
#include "debug_mapper.h"
#include <unistd.h> // sleep for warnings
#include "realm/options.h"

namespace Legion {
namespace Internal {
Expand Down Expand Up @@ -19812,7 +19813,7 @@ namespace Legion {
#endif
realm.init(&argc, &argv);
assert(ok);

{
const ReductionOpTable& red_table = get_reduction_table();
for(ReductionOpTable::const_iterator it = red_table.begin();
Expand All @@ -19828,17 +19829,13 @@ namespace Legion {

// Parse any inputs for the high level runtime
{
#define INT_ARG(argname, varname) do { \
if(!strcmp((argv)[i], argname)) { \
varname = atoi((argv)[++i]); \
continue; \
} } while(0)

#define BOOL_ARG(argname, varname) do { \
if(!strcmp((argv)[i], argname)) { \
varname = true; \
continue; \
} } while(0)
std::vector<std::string> cmdline;
if(argc > 1) {
cmdline.resize(argc - 1);
for(int i = 1; i < argc; i++)
cmdline[i - 1] = argv[i];
}
Realm::OptionParser cp(cmdline);

// Set these values here before parsing the input arguments
// so that we don't need to trust the C runtime to do
Expand Down Expand Up @@ -19889,66 +19886,77 @@ namespace Legion {
bit_mask_logging = false;
#endif
unsigned delay_start = 0;
for (int i = 1; i < argc; i++)
{
BOOL_ARG("-hl:separate",separate_runtime_instances);
BOOL_ARG("-hl:registration",record_registration);
BOOL_ARG("-hl:nosteal",stealing_disabled);
BOOL_ARG("-hl:resilient",resilient_mode);
BOOL_ARG("-hl:unsafe_launch",unsafe_launch);
BOOL_ARG("-hl:unsafe_mapper",unsafe_mapper);
if (!strcmp(argv[i],"-hl:safe_mapper"))
unsafe_mapper = false;
BOOL_ARG("-hl:inorder",program_order_execution);
INT_ARG("-hl:window", initial_task_window_size);
INT_ARG("-hl:hysteresis", initial_task_window_hysteresis);
INT_ARG("-hl:sched", initial_tasks_to_schedule);
INT_ARG("-hl:width", superscalar_width);
INT_ARG("-hl:message",max_message_size);
INT_ARG("-hl:epoch", gc_epoch_size);
if (!strcmp(argv[i],"-hl:no_dyn"))
dynamic_independence_tests = false;
BOOL_ARG("-hl:spy",legion_spy_enabled);
BOOL_ARG("-hl:test",enable_test_mapper);
INT_ARG("-hl:delay", delay_start);
if (!strcmp(argv[i],"-hl:replay"))
{
replay_file = argv[++i];
continue;
}
if (!strcmp(argv[i],"-hl:ldb"))
{
replay_file = argv[++i];
legion_ldb_enabled = true;
continue;
}
#ifdef DEBUG_LEGION
BOOL_ARG("-hl:tree",logging_region_tree_state);
BOOL_ARG("-hl:verbose",verbose_logging);
BOOL_ARG("-hl:logical_only",logical_logging_only);
BOOL_ARG("-hl:physical_only",physical_logging_only);
BOOL_ARG("-hl:disjointness",verify_disjointness);
BOOL_ARG("-hl:bit_masks",bit_mask_logging);

cp.add_option_bool("-hl:separate", separate_runtime_instances);
cp.add_option_bool("-hl:registration", record_registration);
cp.add_option_bool("-hl:nosteal", stealing_disabled);
cp.add_option_bool("-hl:resilient", resilient_mode);
cp.add_option_bool("-hl:unsafe_launch", unsafe_launch);
cp.add_option_bool("-hl:unsafe_mapper", unsafe_mapper);
bool safe_mapper = false;
cp.add_option_bool("-hl:safe_mapper", safe_mapper);
cp.add_option_bool("-hl:inorder", program_order_execution);
cp.add_option_int("-hl:window", initial_task_window_size);
cp.add_option_int("-hl:hysteresis", initial_task_window_hysteresis);
cp.add_option_int("-hl:sched", initial_tasks_to_schedule);
cp.add_option_int("-hl:width", superscalar_width);
cp.add_option_int("-hl:message",max_message_size);
cp.add_option_int("-hl:epoch", gc_epoch_size);
bool nodyn = false;
cp.add_option_bool("-hl:no_dyn", nodyn);
cp.add_option_bool("-hl:spy", legion_spy_enabled);
cp.add_option_bool("-hl:test", enable_test_mapper);
cp.add_option_int("-hl:delay", delay_start);
std::string replay;
cp.add_option_string("-hl:replay", replay);
std::string ldb;
cp.add_option_string("-hl:ldb", ldb);
#ifdef DEBUG_LEGION
cp.add_option_bool("-hl:tree", logging_region_tree_state);
cp.add_option_bool("-hl:verbose", verbose_logging);
cp.add_option_bool("-hl:logical_only", logical_logging_only);
cp.add_option_bool("-hl:physical_only", physical_logging_only);
cp.add_option_bool("-hl:disjointness", verify_disjointness);
cp.add_option_bool("-hl:bit_masks", bit_mask_logging);
#else
if (!strcmp(argv[i],"-hl:tree"))
{
log_run.warning("WARNING: Region tree state logging is "
"disabled. To enable region tree state logging "
"compile in debug mode.");
}
if (!strcmp(argv[i],"-hl:disjointness"))
{
log_run.warning("WARNING: Disjointness verification for "
"partition creation is disabled. To enable dynamic "
"disjointness testing compile in debug mode.");
}
bool tree = false;
cp.add_option_bool("-hl:tree", tree);
bool disjoint = false;
cp.add_option_bool("-hl:disjointness", disjoint);
#endif
INT_ARG("-hl:prof", num_profiling_nodes);
cp.add_option_int("-hl:prof", num_profiling_nodes);
cp.parse_command_line(cmdline);

if (safe_mapper == true) unsafe_mapper = false;

if (nodyn == true) dynamic_independence_tests = false;

if (!replay.empty()) replay_file = replay.c_str();

if (!ldb.empty())
{
replay_file = ldb.c_str();
legion_ldb_enabled = true;
}

#ifndef DEBUG_LEGION
if (tree)
{
log_run.warning("WARNING: Region tree state logging is "
"disabled. To enable region tree state logging "
"compile in debug mode.");
}

if (disjoint)
{
log_run.warning("WARNING: Disjointness verification for "
"partition creation is disabled. To enable dynamic "
"disjointness testing compile in debug mode.");
}
#endif

if (delay_start > 0)
sleep(delay_start);
#undef INT_ARG
#undef BOOL_ARG
#ifdef DEBUG_LEGION
assert(initial_task_window_hysteresis <= 100);
#endif
Expand Down Expand Up @@ -20080,6 +20088,7 @@ namespace Legion {
// Now we can set out input args
Runtime::get_input_args().argv = argv;
Runtime::get_input_args().argc = argc;

// For the moment, we only need to register our runtime tasks
// We'll register everything else once the Legion runtime starts
RtEvent tasks_registered = register_runtime_tasks(realm);
Expand Down
35 changes: 15 additions & 20 deletions runtime/mappers/default_mapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* limitations under the License.
*/

#include "realm/options.h"
#include "legion.h"
#include "default_mapper.h"

Expand Down Expand Up @@ -75,27 +76,21 @@ namespace Legion {
{
int argc = HighLevelRuntime::get_input_args().argc;
char **argv = HighLevelRuntime::get_input_args().argv;
// Parse the input arguments looking for ones for the default mapper
for (int i=1; i < argc; i++)
{
#define INT_ARG(argname, varname) do { \
if (!strcmp(argv[i], argname)) { \
varname = atoi(argv[++i]); \
continue; \
} } while(0);
#define BOOL_ARG(argname, varname) do { \
if (!strcmp(argv[i], argname)) { \
varname = (atoi(argv[++i]) != 0); \
continue; \
} } while(0);
INT_ARG("-dm:thefts", max_steals_per_theft);
INT_ARG("-dm:count", max_steal_count);
BOOL_ARG("-dm:steal", stealing_enabled);
BOOL_ARG("-dm:bft", breadth_first_traversal);
INT_ARG("-dm:sched", max_schedule_count);
#undef BOOL_ARG
#undef INT_ARG
std::vector<std::string> cmdline;
if(argc > 1) {
cmdline.resize(argc - 1);
for(int i = 1; i < argc; i++)
cmdline[i - 1] = argv[i];
}
Realm::OptionParser cp(cmdline);
// Parse the input arguments looking for ones for the default mapper

cp.add_option_int("-dm:thefts", max_steals_per_theft);
cp.add_option_int("-dm:count", max_steal_count);
cp.add_option_bool("-dm:steal", stealing_enabled);
cp.add_option_bool("-dm:bft", breadth_first_traversal);
cp.add_option_int("-dm:sched", max_schedule_count);
cp.parse_command_line(cmdline);
}
if (stealing_enabled)
{
Expand Down
Loading