Permalink
Browse files

Pi example improved by compiling the source code in the working node.

git-svn-id: http://svn.gridway.org/gridway/trunk@220 9b4b2aa8-92f0-458a-8103-c3834d721760
  • Loading branch information...
1 parent bc061a7 commit 5c6cba8cc6a15be71978d731bd8d93f76742c128 alorca committed Feb 3, 2010
Showing with 16 additions and 58 deletions.
  1. +0 −48 examples/pi/Makefile
  2. +4 −0 examples/pi/pi
  3. +3 −1 examples/pi/pi.jt
  4. +9 −9 examples/pi/pi.sh
View
@@ -1,48 +0,0 @@
-#
-# Makefile
-#
-
-# --------------------------------------------------------------------------
-# Copyright 2002-2006 GridWay Team, Distributed Systems Architecture
-# Group, Universidad Complutense de Madrid
-#
-# 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.
-# --------------------------------------------------------------------------
-
-#---------------------------------
-# Compilation Flags and Libraries
-#---------------------------------
-CC = gcc
-
-CFLAGS = -Wall -g
-INCLUDE_FLAGS = -I$(INCLUDE_DIR)
-
-#------------------------
-# Compilation Rules
-#------------------------
-.SUFFIXES: .c .o
-
-.c.o:
- $(CC) $(CFLAGS) $(INCLUDE_FLAGS) -g -c -o $@ $<
-
-#--------------------
-# targets
-#--------------------
-
-all: pi
-
-pi: pi.o
- $(CC) $(CFLAGS) -o pi pi.o
-
-clean:
- @rm -f pi pi.o
View
@@ -0,0 +1,4 @@
+#!/bin/bash
+gcc -Wall -g -c pi.c
+gcc -Wall -g -o pi.out pi.c
+./pi.out $@
View
@@ -1,5 +1,7 @@
EXECUTABLE = pi
ARGUMENTS = ${TASK_ID} ${TOTAL_TASKS} 100000
+INPUT_FILES = pi.c
STDOUT_FILE = stdout_file.${TASK_ID}
STDERR_FILE = stderr_file.${TASK_ID}
-RANK = CPU_MHZ
+RANK = CPU_MHZ
+REQUIREMENTS = ( HOSTNAME = "gilda-ce.rediris.es" )
View
@@ -1,20 +1,20 @@
#!/bin/sh
-
+# Submitting the 4 jobs to GridWay and getting the Array Identificator
AID=`gwsubmit -v -t pi.jt -n 4 | head -1 | awk '{print $3}'`
-if [ $? -ne 0 ]
-then
- echo "Submission failed!"
- exit 1
+# If succeeded we keep further otherwise inform the user
+if [ $? -ne 0 ]; then
+ echo "Submission failed!"
+ exit 1
fi
+# It is time to wait for the collection of 4 jobs to finish, so the user does not receive the shell prompt
gwwait -v -A $AID
+# Once the waiting is over, compute the sum of the stdout_files
if [ $? -eq 0 ]
then
- awk 'BEGIN {sum=0} {sum+=$1} END {printf "Pi is %0.12g\n", sum}' stdout_file.*
+ awk 'BEGIN {sum=0} {sum+=$1} END {printf "Pi is %0.10f\n", sum}' stdout_file.*
else
- echo "Some tasks failed!"
+ echo "Some tasks failed! Check the errors with gwhistory or looking to the $GW_LOCATION/var/\$JOB_ID/job.log"
fi
-
-gwkill -A $AID

0 comments on commit 5c6cba8

Please sign in to comment.