Project

General

Profile

Download (5.07 KB) Statistics
| Branch: | Tag: | Revision:
1
cmake_minimum_required(VERSION 2.8.4)
2
include(FindUnixCommands)
3

    
4

    
5

    
6

    
7

    
8
#take all lustre files
9
set(GLOBAL_LUSTRE_FILES "")
10
LUSTREFILES(LFILES ${CMAKE_CURRENT_SOURCE_DIR} )
11
list(APPEND GLOBAL_LUSTRE_FILES ${LFILES})
12
FOREACH(lfile ${LFILES})
13
	get_filename_component(L ${lfile} NAME_WE)
14
	set(LUSTRE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${L}")
15
	file(COPY ${lfile}   DESTINATION  ${LUSTRE_OUTPUT_DIR})
16
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}.lusi)
17
		file(COPY  ${L}.lusi DESTINATION  ${LUSTRE_OUTPUT_DIR})
18
	else()
19
		message("generate ${L}.lusi \n")
20
		Lustre_Compile(LUS_FILE ${lfile}
21
				NODE ""
22
				OPTS "-lusi")				
23
		set(LUS_OPTS_CUT ${LUSTRE_OPTS_POSTFIX_${L}})
24
		execute_process(RESULT_VARIABLE res 
25
					COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}__${LUS_OPTS_CUT}} 
26
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
27
		if(${res} STREQUAL "0")
28
			file(COPY  ${L}.lusi DESTINATION  ${LUSTRE_OUTPUT_DIR})
29
		else()
30
			message("${L}.lusi Error")
31
		endif()
32
	endif()
33
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}_input_values)
34
		file(COPY  ${L}_input_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
35
	elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}.lusi)
36
		message("generate input_values \n")
37
		execute_process(RESULT_VARIABLE res 
38
					COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ Generate_inputs_lusi top ${L}.lusi 1
39
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
40
		if(${res} STREQUAL "0")
41
			file(COPY  ${L}_input_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
42
		else()
43
			message("${L}_input_values Error")
44
		endif()
45
	endif()
46
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}_output_values)
47
		file(COPY  ${L}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
48
	elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}_input_values)
49
		message("generate output_values for reference \n")
50
		set(LUSTRE_NODE_OPT  "${L}")
51
		
52
		Lustre_Compile(LUS_FILE ${lfile}
53
						NODE ${LUSTRE_NODE_OPT} 
54
						OPTS ""
55
						DIR ${CMAKE_CURRENT_SOURCE_DIR})
56
						
57
		set(LUS_OPTS_CUT ${LUSTRE_OPTS_POSTFIX_${L}})
58
		
59
		execute_process(
60
					COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}} 
61
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})			
62
		execute_process(
63
					COMMAND  make -f ${L}.makefile
64
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})	
65
		execute_process(RESULT_VARIABLE res 
66
					COMMAND ${BASH} -c "./${L}_${LUSTRE_NODE_OPT} < ${L}_input_values > ${L}_output_values"
67
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})	
68
		file(REMOVE ${L}_${LUSTRE_NODE_OPT} io_frontend.o ${L}.c ${L}.h ${L}.lusic ${L}.makefile ${L}.o ${L}_alloc.h ${L}_main.c ${L}_main.o )
69
		if(${res} STREQUAL "0")
70
			file(COPY  ${L}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
71
		else()
72
			message("${L} output_values Error")
73
		endif()
74
	endif()
75
ENDFOREACH()
76

    
77

    
78

    
79
FOREACH(lus_file ${GLOBAL_LUSTRE_FILES})
80
	get_filename_component(L ${lus_file} NAME_WE)
81
	set(LUSTRE_NODE_OPT  "${L}")
82

    
83

    
84
	#first combination :mpfr
85
	set(LUSTRE_OPTIONS_OPT "-mpfr" "100")
86
	set(EPSILON "0.0001")
87
	
88
	# First command generate C files from Lustre file
89
	Lustre_Compile(LUS_FILE ${lus_file}
90
					NODE ${LUSTRE_NODE_OPT}
91
					OPTS ${LUSTRE_OPTIONS_OPT}
92
					CALL_ID "2")
93
					
94
	set(LUS_OPTS_CUT_2 "${LUSTRE_OPTS_POSTFIX_${L}_2}")
95
	add_test(NAME mpfr_COMPIL_LUSTRE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}
96
			COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}} 
97
	)
98

    
99
	 #********************* make -f ${L}.makefile ***************************
100
	 add_test(NAME mpfr_MAKE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}
101
			COMMAND  make -f ${L}.makefile
102
			WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}}
103
	)
104
	SET_TESTS_PROPERTIES ( mpfr_MAKE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}
105
	 PROPERTIES DEPENDS mpfr_COMPIL_LUSTRE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}
106
				REQUIRED_FILES ${L}.makefile
107
				)
108
	 
109
	 #************** execute C binary **********************************
110
	
111
	if (BASH)
112
		add_test(
113
			NAME mpfr_BIN_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2} 
114
			COMMAND ${BASH} -c "./${L}_${LUSTRE_NODE_OPT} < ../${L}_input_values > ${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}_outputs"
115
			WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}}
116
		)
117
		SET_TESTS_PROPERTIES ( mpfr_BIN_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}
118
			PROPERTIES REQUIRED_FILES ${L}_${LUSTRE_NODE_OPT}
119
				DEPENDS mpfr_MAKE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2})
120
	else()
121
		message(FATAL_ERROR "Unknown shell command ${BASH} -c for ${CMAKE_HOST_SYSTEM_NAME}")
122
	endif()
123
	
124
	 #************** execute C binary **********************************
125
	 add_test(NAME mpfr_DIFF_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}
126
COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ compare_lustrec_outputs ${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}_outputs ../${L}_output_values ${EPSILON}
127
	   WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}}
128
	)
129
	SET_TESTS_PROPERTIES ( mpfr_DIFF_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}
130
	 PROPERTIES REQUIRED_FILES ${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2}_outputs
131
				DEPENDS mpfr_BIN_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT_2} )
132

    
133

    
134

    
135

    
136
ENDFOREACH()
137

    
138
add_custom_target(mpfr COMMAND ${CMAKE_CTEST_COMMAND} -R mpfr)
139

    
(1-1/17)