Skip to content

Commit

Permalink
Realm: Adding original Legion files to enable hello_world
Browse files Browse the repository at this point in the history
Adding source files that need to be modified to enable
00_hello_world example from the original codebase

Change-Id: Ie2e71a97603a78caea2471ab477e9b0c56589eac
  • Loading branch information
srirajpaul committed Jul 27, 2016
1 parent 5d034ec commit 6576054
Show file tree
Hide file tree
Showing 4 changed files with 29,397 additions and 0 deletions.
50 changes: 50 additions & 0 deletions hll/legion-realm/patch/examples/00_hello_world/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2016 Stanford University
#
# 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.
#


ifndef LG_RT_DIR
$(error LG_RT_DIR variable is not defined, aborting build)
endif

# Flags for directing the runtime makefile what to include
DEBUG ?= 1 # Include debugging symbols
OUTPUT_LEVEL ?= LEVEL_DEBUG # Compile time logging level
SHARED_LOWLEVEL ?= 0 # Use shared-memory runtime (not recommended)
USE_CUDA ?= 0 # Include CUDA support (requires CUDA)
USE_GASNET ?= 0 # Include GASNet support (requires GASNet)
USE_HDF ?= 0 # Include HDF5 support (requires HDF5)
ALT_MAPPERS ?= 0 # Include alternative mappers (not recommended)

# Put the binary file name here
OUTFILE ?= hello_world
# List all the application source files here
GEN_SRC ?= hello_world.cc # .cc files
GEN_GPU_SRC ?= # .cu files

# You can modify these variables, some will be appended to by the runtime makefile
INC_FLAGS ?=
CC_FLAGS ?=
NVCC_FLAGS ?=
GASNET_FLAGS ?=
LD_FLAGS ?=

###########################################################################
#
# Don't change anything below here
#
###########################################################################

include $(LG_RT_DIR)/runtime.mk

63 changes: 63 additions & 0 deletions hll/legion-realm/patch/examples/00_hello_world/hello_world.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Copyright 2016 Stanford University
*
* 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.
*/


#include <cstdio>

#include "legion.h"

// All of the important user-level objects live
// in the high-level runtime namespace.
using namespace LegionRuntime::HighLevel;

// We use an enum to declare the IDs for user-level tasks
enum TaskID {
HELLO_WORLD_ID,
};

// All single-launch tasks in Legion must have this signature with
// the extension that they can have different return values.
void hello_world_task(const Task *task,
const std::vector<PhysicalRegion> &regions,
Context ctx, HighLevelRuntime *runtime)
{
// A task runs just like a normal C++ function.
printf("Hello World!\n");
}

// We have a main function just like a standard C++ program.
// Once we start the runtime, it will begin running the top-level task.
int main(int argc, char **argv)
{
// Before starting the Legion runtime, you first have to tell it
// what the ID is for the top-level task.
HighLevelRuntime::set_top_level_task_id(HELLO_WORLD_ID);
// Before starting the Legion runtime, all possible tasks that the
// runtime can potentially run must be registered with the runtime.
// The function pointer is passed as a template argument. The second
// argument specifies the kind of processor on which the task can be
// run: latency optimized cores (LOC) aka CPUs or throughput optimized
// cores (TOC) aka GPUs. The last two arguments specify whether the
// task can be run as a single task or an index space task (covered
// in more detail in later examples). The top-level task must always
// be able to be run as a single task.
HighLevelRuntime::register_legion_task<hello_world_task>(HELLO_WORLD_ID,
Processor::LOC_PROC, true/*single*/, false/*index*/);

// Now we're ready to start the runtime, so tell it to begin the
// execution. We'll never return from this call, but its return
// signature will return an int to satisfy the type checker.
return HighLevelRuntime::start(argc, argv);
}
Loading

0 comments on commit 6576054

Please sign in to comment.