Tutorial:
Makefile for running remote programs in Legion 1.5

Table of Contents

  About this makefile
Sample makefile

  Other relevant on-line documents:
  Logging in to a running Legion system
Legion graphical user interface
Introduction to Legion context space
Context-related commands
How to start remote programs in Legion
Sample makefile for remote programs
Object permissions
Legion tty objects
Running a PVM code in Legion
Running an MPI code in Legion
Quick list of all Legion commands
Usage of all Legion commands
Starting and shutting down Legion 1.5
Using Legion security features
Legion host and vault objects
Adding host and vault objects
The list of all on-line 1.5 tutorials


The Legion tutorials offer quick and simple instructions for various key procedures for a Legion system. More complete explanations of all of the procedures discussed here are available on separate pages, and can be found by clicking on the icon.

Depending on how your system is set up, you may need to set up your access to your system before you can run Legion commands. This will probably involve running a command such as this:

$ . ~legion/setup.sh

or

$ source ~legion/setup.csh
The exact syntax will depend on what kind of shell you are using and where your Legion files are installed (i.e., the value of ~legion will depend on your individual Legion net). Consult your system administrator for more information.


About this makefile

This makefile is for use with both legacy and Legion-aware programs that will be executed with either legion_run or legion_run_multi. In the sample below we started with a legacy C++ code, gnomad.c, and modified it to use the Legion I/O libraries. This allows the application to manipulate context space directly rather than copying a lot of files around. A copy of the original program was kept in the file gnomad_orig.c.

The makefile has targets for five platforms: intel, sgi, solaris, ibm, and alpha_linux. The make targets are slightly different for each machine because the c++/g++ compiler sits in different places and may not be found by the default search path. Therefore, we hard-wired each target to known paths. If these paths don't work for you, log on to a compilation box and get the path directly.

Each make target uses legion_make to start a make on the desired platform. The make target then compiles and registers both the pure legacy code and the Legion-aware code. After each code is compiled, the resulting binary is registered in Legion space in the desired directory, in this case in /home/grimshaw.


Sample makefile

CC	= g++

include $(LEGION)/src/macros/$(LEGION_ARCH).macros

include $(LEGION)/src/macros/$(LEGION_ARCH).$(CC).macros

CFLAGS	= -I$(LEGION)/include -L$(LEGION)/lib/$(LEGION_ARCH)/g++ 
LIB = -lBasicFiles -lLegionClientStubs $(LIB_LEGION_LFLAGS)

local:
	g++ -O $(CFLAGS) gnomad.c -o gnomad $(LIB)
	g++ -O $(CFLAGS) gnomad_orig.c -o gnomad_orig $(LIB)

intel:	gnomad.c
	legion_make -a linux usr_path 
	touch intel

all_platforms: solaris ibm intel alpha_linux sgi
	make intel alpha_linux solaris sgi

gnu_path:
	/gnu/bin/g++ -O $(CFLAGS) gnomad.c -o gnomad $(LIB) 
	legion_register_program /home/grimshaw/gnomad ./gnomad $(LEGION_ARCH)
	/gnu/bin/g++ -O $(CFLAGS) gnomad_orig.c -o gnomad_orig $(LIB) 
	legion_register_program /home/grimshaw/gnomad_orig ./gnomad_orig $(LEGION_ARCH)

usr_local_path:
	/usr/local/bin/g++  -O $(CFLAGS) gnomad.c -o gnomad $(LIB) 
	legion_register_program /home/grimshaw/gnomad ./gnomad $(LEGION_ARCH)
	/usr/local/bin/g++  -O $(CFLAGS) gnomad_orig.c -o gnomad_orig $(LIB) 
	legion_register_program /home/grimshaw/gnomad_orig ./gnomad_orig $(LEGION_ARCH)

usr_path:
	/usr/bin/g++  -O $(CFLAGS) gnomad.c -o gnomad $(LIB) 
	legion_register_program /home/grimshaw/gnomad ./gnomad $(LEGION_ARCH)
	/usr/bin/g++  -O $(CFLAGS) gnomad_orig.c -o gnomad_orig $(LIB) 
	legion_register_program /home/grimshaw/gnomad_orig ./gnomad_orig $(LEGION_ARCH)

solaris:	gnomad.c
	legion_make -a solaris -e /gnu/bin/make gnu_path
	touch solaris

ibm:	gnomad.c
	legion_make -a rs6000 -e /gnu/bin/make gnu_path
	touch ibm

sgi:	gnomad.c
	legion_make -h /hosts/bluebox.cs.virginia.edu -e /gnu/bin/make gnu_path
	touch sgi

alpha_linux:	gnomad.c
	legion_make -a alpha_linux usr_local_path
	touch alpha_linux

register:
	legion_register_program /home/grimshaw/gnomad ./gnomad $(LEGION_ARCH)

clean:
	rm -f gnomad solaris ibm sgi intel alpha_linux

run:
	legion_run -IN ribo.x -IN ribo.d -IN params -OUT tmaplow -OUT tmapfinal gnomad ribo