Skip to content

Commit

Permalink
Cleaned up. Added some neglected files. Added .gitignores.
Browse files Browse the repository at this point in the history
  • Loading branch information
rrnewton committed Mar 3, 2011
1 parent 4612ee9 commit 4191110
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
*.o
*.hi
*~
dist/
scrap
4 changes: 4 additions & 0 deletions Intel/Cnc/Spec/Curses.hs
@@ -1,5 +1,9 @@
{-# LANGUAGE RecordWildCards #-}

{-|
A Curses-based user interface.
-}

module Intel.Cnc.Spec.Curses where

--import System.IO
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -207,7 +207,7 @@ wctrans:

#====================================================================================================

clean: cleanruntime cleantrans
clean: cleanruntime cleantrans cleantests
runhaskell ./Setup.hs clean

cleanruntime:
Expand All @@ -225,6 +225,9 @@ cleantrans:
(cd ./Intel/Cnc/Spec; find -name "*.o" | xargs -i rm {} )
(cd ./Intel/Cnc/Spec; find -name "*.hi" | xargs -i rm {} )

cleantests:
(cd tests_spec; $(MAKE) clean)


#====================================================================================================

Expand Down
2 changes: 1 addition & 1 deletion TODO.txt
Expand Up @@ -35,7 +35,7 @@ Things to work on:
Tag functions:

(*) Generate tag-function-correctess-enforcing code for all gets and puts.
(Generalize this functionality and put it in a plugin.)
[partially done] NEXT: Generalize this functionality and put it in a plugin.

Correctness checking:

Expand Down
18 changes: 18 additions & 0 deletions nightly_test.hs
@@ -0,0 +1,18 @@
#!/usr/bin/env runhaskell

import System.Directory
import HSH

-- cd = setCurrentDirectory


publishdir = "/var/www/nightlytest/Haskell-CnC/"

main = do

putStrLn "Running full nightly regression tests in the current directory."

-- runIO "git clone git://github.com/rrnewton/Haskell-CnC.git"
-- cd "Haskell-CnC"

putStrLn "Done with all regression testing."
3 changes: 3 additions & 0 deletions tests_spec/.gitignore
@@ -0,0 +1,3 @@
*.out
*.ERR

42 changes: 32 additions & 10 deletions tests_spec/Makefile
@@ -1,10 +1,20 @@

FLAGS= -I$(CNC_INSTALL_DIR)/include -L$(CNC_INSTALL_DIR)/lib/$(CNC_ARCH_PLATFORM) -ltbbmalloc -ltbb -lcnc
# Use "make" and "make test"

FLAGS= -I$(CNC_INSTALL_DIR)/include -L$(CNC_INSTALL_DIR)/lib/$(CNC_ARCH_PLATFORM) -I. \
-ltbbmalloc -ltbb -lcnc

EXES= tagfun_checking_valid.exe tagfun_depends.exe \
simple_cycle.exe bigger_cycle.exe two_cycles.exe \
reduction_test.exe reduction_test2.exe
CC=g++

# These main tests are the ones for which we have full (.cpp) programs
# as well as just specs to translate.
MAINTESTS= tagfun_checking_valid.cnc tagfun_depends.cnc \
simple_cycle.cnc bigger_cycle.cnc two_cycles.cnc \
reduction_test.cnc reduction_test2.cnc

MAINEXES= $(MAINTESTS:.cnc=.exe)

OTHERTESTS= cholesky.cnc mandel.cnc eigensolver.cnc

ERRONEOUS = legacy/test001.cnc \
legacy/test007.cnc \
Expand Down Expand Up @@ -165,7 +175,8 @@ ifeq (Darwin,$(shell uname))
FLAGS+= -m32
endif

all: $(EXES)
all: mainexes
mainexes: $(MAINEXES)

test: run
run:
Expand All @@ -181,15 +192,20 @@ run:
@$(MAKE) check_bad
@echo
@echo
@$(MAKE) all
@echo
@echo "Running full system tests (code and spec):"
@echo "================================================================================"
@$(MAKE) maintests

maintests:
@$(MAKE) mainexes
@echo
runhaskell ./run_tests.hs

bad: check_bad
check_bad:
./run_erroneous.sh $(ERRONEOUS:.cnc=.h)
@echo
@echo "All tests that should fail did fail."

good: check_good
check_good:
Expand All @@ -207,6 +223,9 @@ CNCTOOL=$(shell ./first_existing.sh ../build/cnc ../dist/build/cnc/cnc ../cnc.sh
tagfun_checking_valid.h: tagfun_checking_valid.cnc
$(CNCTOOL) trans --autodonedbg --debug $<

tagfun_checking_invalid.exe: tagfun_checking_invalid.cpp tagfun_checking_valid.h
time $(CC) $(FLAGS) $< -o $@

tagfun_depends.h: tagfun_depends.cnc
$(CNCTOOL) trans --autodonedbg --depends $<

Expand All @@ -217,11 +236,14 @@ tagfun_depends.h: tagfun_depends.cnc
#============================================================

%.exe : %.cpp %.h
time g++ $(FLAGS) $< -o $@
time $(CC) $(FLAGS) $< -o $@
@echo
@echo

clean:
rm -f *.o *.exe tagfun_checking_valid.h tagfun_depends.h simple_cycle.h bigger_cycle.h
rm -f $(ERRONEOUS:.cnc=.h) $(WELLFORMED:.cnc=.h)
rm -f *.o *.exe run_tests
rm -f $(MAINTESTS:.cnc=.h) $(OTHERTESTS:.cnc=.h)
#tagfun_checking_valid.h tagfun_depends.h simple_cycle.h bigger_cycle.h
rm -f $(ERRONEOUS:.cnc=.h) $(WELLFORMED:.cnc=.h)o $(DISCREPANCIES:.cnc=.h)
rm -f *.ERR legacy/*.ERR

11 changes: 11 additions & 0 deletions tests_spec/README.txt
@@ -0,0 +1,11 @@


[2011.01.04]

This directory contains a number of tests that exercise the
translator. To perform tests it is also necessary to have a working
installation of the Intel CnC for C++ library.

Currently this directory contains a makefile for building tests, as
well as a Haskell script for running them (run_tests.hs).

17 changes: 17 additions & 0 deletions tests_spec/legacy/test087B.cnc
@@ -0,0 +1,17 @@
//Each name starts and ends with '_'
//a starting '_' is omitted

//Is correct: Yes

(_Work_);
(_Start_);
[_type_ _item_ <_int_>];
<_int_ _singleton_>;
<_singleton_> :: (_Start_);
<_int_ _worker_>;
<_worker_> :: (_Work_);
env -> <_singleton_>;
(_Start_) -> [_item_];
(_Start_) -> <_worker_>;
(_Work_) -> [_item_];
[_item_] -> env;
15 changes: 10 additions & 5 deletions tests_spec/run_tests.hs
Expand Up @@ -85,11 +85,15 @@ test_cases numthreads tests =

each_test numthreads (name, project) =
testCase "" ("Running, " ++ numthreads ++" thread(s): "++ name ) $ test $
do out <- run$ setenv [("CNC_NUM_THREADS", numthreads)] $
("./"++ name ++".exe") -|- tee [name++".out"]
do
-- Gather the stdout output from the test run:
-- (TODO NOTE: Any good way to capture stderr here?)
output <- run$ setenv [("CNC_NUM_THREADS", numthreads)] $
("./"++ name ++".exe") -|- tee [name++".out"]
expected <- readFile$ name ++ ".cmpr"

let s1 = S.fromList $ map project $ lines out
-- Convert the outputs to sets and do unordered comparison:
let s1 = S.fromList $ map project $ lines output
s2 = S.fromList $ map project $ lines expected
set_eq = s1 == s2

Expand All @@ -98,7 +102,8 @@ each_test numthreads (name, project) =
d2 = S.difference s2 s1

putStrLn$ " FAIL: "
putStrLn$ " Output string length "++ show (length (out::String)) ++", expected length " ++ show (length expected)
putStrLn$ " Output string length "++ show (length (output::String))
++", expected length " ++ show (length expected)
-- putStrLn$ " Output/expected equal? "++ show (out == expected)
-- putStrLn$ " Output/expected lines set-equal? "++ show set_eq

Expand Down Expand Up @@ -178,6 +183,6 @@ trans file =
putStrLn$ "\nTranslating .cnc file: "++ file
putStrLn$ "================================================================================"
let cmd = cnc ++ " trans " ++ dubquote file
putStrLn$ "Running command: " ++ cmd
putStrLn$ "/Running command: " ++ cmd
runIO$ cmd

64 changes: 64 additions & 0 deletions tests_spec/tagfun_checking_invalid.cpp
@@ -0,0 +1,64 @@

// This version uses the same .cnc file but breaks the rules.

#include<tagfun_checking_valid.h>

template < class ctxt >
int S1::execute( const int & tag, ctxt & c) const {
printf("Step1 exec with tag %d\n", tag);
c.T2.put(tag);
return CnC::CNC_Success;
}

template < class ctxt >
int S2::execute( const int & tag, ctxt & c) const {
printf("Step2 exec with tag %d\n", tag);
// VIOLATE THE TAG FUNCTION HERE, +2 instead of +1:
c.I.put(tag + 2, (tag * 3.33));
return CnC::CNC_Success;
}

int main () {
printf ("Running with tagfun checking.\n");
tagfun_checking_valid_context context;

// Put some tags into the collection in a naive way:
for(int i=0; i<5; i++)
context.T1.put(i);

context.wait();

double fl;
context.I.get(3, fl);
printf("Retrieve a single item, index 3: %lf\n", fl);
return 0;
}



// template < class ctxt >
// int S::execute( const int & tag, ctxt & c) const {
// printf("Step exec with tag %d\n", tag);

// // VIOLATE THE TAG FUNCTION HERE:
// c.I.put(tag + 2, (tag * 3.33));

// return CnC::CNC_Success;
// }

// int main () {
// printf ("Running with tagfun checking.\n");
// tagfun_checking_valid_context context;

// // Put some tags into the collection in a naive way:
// for(int i=0; i<10; i++)
// context.T.put(i);

// context.wait();

// double fl;
// context.I.get(3, fl);

// printf("Retrieve a single item, index 3: %lf\n", fl);
// return 0;
// }

0 comments on commit 4191110

Please sign in to comment.