Skip to content

Commit 8301a16

Browse files
author
CharCoding
committed
Finish HTML version
1 parent b447f26 commit 8301a16

File tree

7 files changed

+486
-751
lines changed

7 files changed

+486
-751
lines changed

16x

12.7 MB
Binary file not shown.

Makefile

Lines changed: 22 additions & 294 deletions
Original file line numberDiff line numberDiff line change
@@ -1,301 +1,29 @@
1-
## EECS 281 Advanced Makefile
1+
CXX = g++ -std=c++20
22

3-
# How to use this Makefile...
4-
###################
5-
###################
6-
## ##
7-
## $ make help ##
8-
## ##
9-
###################
10-
###################
3+
all: chomp solver
114

12-
# IMPORTANT NOTES:
13-
# 1. Set EXECUTABLE to the command name from the project specification.
14-
# 2. To enable automatic creation of unit test rules, your program logic
15-
# (where main() is) should be in a file named project*.cpp or
16-
# specified in the PROJECTFILE variable.
17-
# 3. Files you want to include in your final submission cannot match the
18-
# test*.cpp pattern.
5+
chomp: chomp.cpp chomp.h
6+
$(CXX) -O3 chomp.cpp -o chomp
197

20-
#######################
21-
# TODO (begin) #
22-
#######################
23-
# Change IDENTIFIER to match the project identifier given in the project spec.
24-
IDENTIFIER = EEC50281EEC50281EEC50281EEC50281EEC50281
8+
solver: solver.cpp
9+
$(CXX) -O3 solver.cpp -o solver
2510

26-
# Change 'executable' to match the command name given in the project spec.
27-
EXECUTABLE = chomp
11+
solver_compressed: solver.cpp
12+
$(CXX) -O3 -D COMPRESS solver.cpp -o solver_compressed
2813

29-
# The following line looks for a project's main() in files named project*.cpp,
30-
# executable.cpp (substituted from EXECUTABLE above), or main.cpp
31-
PROJECTFILE = $(or $(wildcard project*.cpp $(EXECUTABLE).cpp), main.cpp)
32-
# If main() is in another file delete line above, edit and uncomment below
33-
#PROJECTFILE = mymainfile.cpp
34-
#######################
35-
# TODO (end) #
36-
#######################
14+
debug: chomp.cpp chomp.h
15+
$(CXX) -g3 -DDEBUG chomp.cpp -o chomp_debug
3716

38-
# enables c++17 on CAEN or 281 autograder
39-
PATH := /usr/um/gcc-6.2.0/bin:$(PATH)
40-
LD_LIBRARY_PATH := /usr/um/gcc-6.2.0/lib64
41-
LD_RUN_PATH := /usr/um/gcc-6.2.0/lib64
42-
43-
# This is the path from the CAEN home folder to where projects will be
44-
# uploaded. (eg. /home/mmdarden/eecs281/project1)
45-
# Change this if you prefer a different path.
46-
# REMOTE_PATH := eecs281_$(EXECUTABLE)_sync # /home/mmdarden/eecs281_proj0_sync
47-
REMOTE_PATH := eecs281_$(EXECUTABLE)_sync
48-
49-
# designate which compiler to use
50-
CXX = g++
51-
52-
# list of test drivers (with main()) for development
53-
TESTSOURCES = $(wildcard test*.cpp)
54-
# names of test executables
55-
TESTS = $(TESTSOURCES:%.cpp=%)
56-
57-
# list of sources used in project
58-
SOURCES = $(wildcard *.cpp)
59-
SOURCES := $(filter-out $(TESTSOURCES), $(SOURCES))
60-
# list of objects used in project
61-
OBJECTS = $(SOURCES:%.cpp=%.o)
62-
63-
# name of the tarball created for submission
64-
FULL_SUBMITFILE = fullsubmit.tar.gz
65-
PARTIAL_SUBMITFILE = partialsubmit.tar.gz
66-
UNGRADED_SUBMITFILE = ungraded.tar.gz
67-
68-
# name of the perf data file, only used by the clean target
69-
PERF_FILE = perf.data*
70-
71-
#Default Flags (we prefer -std=c++17 but Mac/Xcode/Clang doesn't support)
72-
CXXFLAGS = -std=c++20 # -Wall -Wextra -pedantic
73-
74-
# make release - will compile "all" with $(CXXFLAGS) and the -O3 flag
75-
# also defines NDEBUG so that asserts will not check
76-
release: CXXFLAGS += -O3 -DNDEBUG
77-
release: $(EXECUTABLE)
78-
79-
# make debug - will compile sources with $(CXXFLAGS) and the -g3 flag
80-
# also defines DEBUG, so "#ifdef DEBUG /*...*/ #endif" works
81-
debug: CXXFLAGS += -g3 -DDEBUG
82-
debug:
83-
$(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXECUTABLE)_debug
84-
85-
# make profile - will compile "all" with $(CXXFLAGS) and the -g3 and -O3 flags
86-
profile: CXXFLAGS += -g3 -O3
87-
profile:
88-
$(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXECUTABLE)_profile
89-
90-
# make gprof - will compile "all" with $(CXXFLAGS) and the -pg (for gprof)
91-
gprof: CXXFLAGS += -pg
92-
gprof:
93-
$(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXECUTABLE)_profile
94-
95-
# make static - will perform static analysis in the matter currently used
96-
# on the autograder
97-
static:
98-
cppcheck --enable=all --suppress=missingIncludeSystem \
99-
$(SOURCES) *.h *.hpp
100-
101-
# make identifier - will check to ensure that all source code and header files
102-
# include the project identifier; skip subdirectories;
103-
# also removes old submit tarballs, they are outdated
104-
identifier:
105-
@if [ $$(grep --include=*.{h,hpp,c,cpp} --exclude=xcode_redirect.hpp --directories=skip -L $(IDENTIFIER) * | wc -l) -ne 0 ]; then \
106-
printf "Missing project identifier in file(s): "; \
107-
echo `grep --include=*.{h,hpp,c,cpp} --directories=skip -L $(IDENTIFIER) *`; \
108-
rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE); \
109-
exit 1; \
110-
fi
111-
112-
# Build all executables
113-
all: release debug profile
114-
115-
$(EXECUTABLE): $(OBJECTS)
116-
ifeq ($(EXECUTABLE), executable)
117-
@echo Edit EXECUTABLE variable in Makefile.
118-
@echo Using default a.out.
119-
$(CXX) $(CXXFLAGS) $(OBJECTS)
120-
else
121-
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $(EXECUTABLE)
122-
endif
123-
124-
# Automatically generate any build rules for test*.cpp files
125-
define make_tests
126-
ifeq ($$(PROJECTFILE),)
127-
@echo Edit PROJECTFILE variable to .cpp file with main\(\)
128-
@exit 1
129-
endif
130-
SRCS = $$(filter-out $$(PROJECTFILE), $$(SOURCES))
131-
OBJS = $$(SRCS:%.cpp=%.o)
132-
HDRS = $$(wildcard *.h *.hpp)
133-
$(1): CXXFLAGS += -g3 -DDEBUG
134-
$(1): $$(OBJS) $$(HDRS) $(1).cpp
135-
$$(CXX) $$(CXXFLAGS) $$(OBJS) $(1).cpp -o $(1)
136-
endef
137-
$(foreach test, $(TESTS), $(eval $(call make_tests, $(test))))
138-
139-
alltests: $(TESTS)
140-
141-
# rule for creating objects
142-
%.o: %.cpp
143-
$(CXX) $(CXXFLAGS) -c $*.cpp
144-
145-
# make clean - remove .o files, executables, tarball
14617
clean:
147-
rm -f $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE)_debug $(EXECUTABLE)_profile \
148-
$(TESTS) $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(PERF_FILE) \
149-
$(UNGRADED_SUBMITFILE)
150-
rm -Rf *.dSYM
151-
152-
153-
# get a list of all files that might be included in a submit
154-
# different submit types can do additional filtering to remove unwanted files
155-
FULL_SUBMITFILES=$(filter-out $(TESTSOURCES), \
156-
$(wildcard Makefile *.h *.hpp *.cpp test*.txt))
157-
158-
# make fullsubmit.tar.gz - cleans, runs dos2unix, creates tarball
159-
# including test files
160-
$(FULL_SUBMITFILE): $(FULL_SUBMITFILES)
161-
rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(UNGRADED_SUBMITFILE)
162-
COPYFILE_DISABLE=true tar -vczf $(FULL_SUBMITFILE) $(FULL_SUBMITFILES)
163-
@echo !!! Final submission prepared, test files included... READY FOR GRADING !!!
164-
165-
# make partialsubmit.tar.gz - cleans, creates tarball
166-
# omitting test files
167-
PARTIAL_SUBMITFILES=$(filter-out $(wildcard test*.txt), $(FULL_SUBMITFILES))
168-
$(PARTIAL_SUBMITFILE): $(PARTIAL_SUBMITFILES)
169-
rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(UNGRADED_SUBMITFILE)
170-
COPYFILE_DISABLE=true tar -vczf $(PARTIAL_SUBMITFILE) \
171-
$(PARTIAL_SUBMITFILES)
172-
@echo !!! WARNING: No test files included. Use 'make fullsubmit' to include test files. !!!
173-
174-
# make ungraded.tar.gz - cleans, creates tarball omitting test files, Makefile
175-
UNGRADED_SUBMITFILES=$(filter-out Makefile, $(PARTIAL_SUBMITFILES))
176-
$(UNGRADED_SUBMITFILE): $(UNGRADED_SUBMITFILES)
177-
rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(UNGRADED_SUBMITFILE)
178-
@touch __ungraded
179-
COPYFILE_DISABLE=true tar -vczf $(UNGRADED_SUBMITFILE) \
180-
$(UNGRADED_SUBMITFILES) __ungraded
181-
@rm -f __ungraded
182-
@echo !!! WARNING: This submission will not be graded. !!!
183-
184-
# shortcut for make submit tarballs
185-
fullsubmit: identifier $(FULL_SUBMITFILE)
186-
partialsubmit: identifier $(PARTIAL_SUBMITFILE)
187-
ungraded: identifier $(UNGRADED_SUBMITFILE)
188-
189-
# REMOTE_PATH has default definition above
190-
sync2caen:
191-
# Synchronize local files into target directory on CAEN
192-
rsync \
193-
-av \
194-
--delete \
195-
--exclude '*.o' \
196-
--exclude '$(EXECUTABLE)' \
197-
--exclude '$(EXECUTABLE)_debug' \
198-
--exclude '$(EXECUTABLE)_profile' \
199-
--exclude '.git*' \
200-
--exclude '.vs*' \
201-
--exclude '*.code-workspace' \
202-
--filter=":- .gitignore" \
203-
"."/ \
204-
"[email protected]:'$(REMOTE_PATH)/'"
205-
echo "Files synced to CAEN at ~/$(REMOTE_PATH)/"
206-
207-
define MAKEFILE_HELP
208-
EECS281 Advanced Makefile Help
209-
* This Makefile uses advanced techniques, for more information:
210-
$$ man make
211-
212-
* General usage
213-
1. Follow directions at each "TODO" in this file.
214-
a. Set EXECUTABLE equal to the name from the project specification.
215-
b. Set PROJECTFILE equal to the name of the source file with main()
216-
c. Add any dependency rules specific to your files.
217-
2. Build, test, submit... repeat as necessary.
218-
219-
* Preparing submissions
220-
A) To build 'partialsubmit.tar.gz', a tarball without tests used to
221-
find buggy solutions in the autograder.
222-
223-
*** USE THIS ONLY FOR TESTING YOUR SOLUTION! ***
224-
225-
This is useful for faster autograder runs during development and
226-
free submissions if the project does not build.
227-
$$ make partialsubmit
228-
B) Build 'fullsubmit.tar.gz' a tarball complete with autograder test
229-
files.
230-
231-
*** ALWAYS USE THIS FOR FINAL GRADING! ***
232-
233-
It is also useful when trying to find buggy solutions in the
234-
autograder.
235-
$$ make fullsubmit
236-
237-
* Unit testing support
238-
A) Source files for unit testing should be named test*.cpp. Examples
239-
include test_input.cpp or test3.cpp.
240-
B) Automatic build rules are generated to support the following:
241-
$$ make test_input
242-
$$ make test3
243-
$$ make alltests (this builds all test drivers)
244-
C) If test drivers need special dependencies, they must be added
245-
manually.
246-
D) IMPORTANT: NO SOURCE FILES WITH NAMES THAT BEGIN WITH test WILL BE
247-
ADDED TO ANY SUBMISSION TARBALLS.
248-
249-
* Static Analysis support
250-
A) Matches current autograder style grading tests
251-
B) Usage:
252-
$$ make static
253-
254-
* Sync to CAEN support
255-
A) Requires an .ssh/config file with a login.engin.umich.edu host
256-
defined, SSH Multiplexing enabled, and an open SSH connection.
257-
B) Edit the REMOTE_BASEDIR variable if default is not preferred.
258-
C) Usage:
259-
$$ make sync2caen
260-
endef
261-
export MAKEFILE_HELP
262-
263-
help:
264-
@echo "$$MAKEFILE_HELP"
265-
266-
#######################
267-
# TODO (begin) #
268-
#######################
269-
# individual dependencies for objects
270-
# Examples:
271-
# "Add a header file dependency"
272-
# project2.o: project2.cpp project2.h
273-
#
274-
# "Add multiple headers and a separate class"
275-
# HEADERS = some.h special.h header.h files.h
276-
# myclass.o: myclass.cpp myclass.h $(HEADERS)
277-
# project5.o: project5.cpp myclass.o $(HEADERS)
278-
#
279-
# SOME EXAMPLES
280-
#
281-
#test_thing: test_thing.cpp class.o functions.o
282-
#class.o: class.cpp class.h
283-
#functions.o: functions.cpp functions.h
284-
#project0.o: project0.cpp class.h functions.h
285-
#
286-
# THE COMPILER CAN GENERATE DEPENDENCIES FROM SOURCE CODE
287-
#
288-
# % g++ -MM *.cpp
289-
#
290-
# ADD YOUR OWN DEPENDENCIES HERE
291-
chomp.o: chomp.cpp chomp.h
292-
test.o: test.cpp chomp.h
293-
######################
294-
# TODO (end) #
295-
######################
296-
297-
# these targets do not create any files
298-
.PHONY: all release debug profile static clean alltests partialsubmit \
299-
fullsubmit ungraded sync2caen help identifier
300-
# disable built-in rules
301-
.SUFFIXES:
18+
rm chomp chomp_debug solver
19+
20+
# expect 4.5 minutes of computing time
21+
# output is stored in binary file "16x", 12.7 MiB
22+
# can be compressed to 4.0 MiB using code commented out in solver.cpp
23+
# decompress program left as exercise to reader
24+
solve: solver
25+
./solver
26+
27+
.PHONY: all chomp solver solver_compressed debug clean solve
28+
# static:
29+
# cppcheck --enable=all --suppress=missingIncludeSystem *.h *.cpp

chomp.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ Better square counting:
3939
pos = 01001100011100001111: 20 bit, maxX = maxY = 10
4040
naive algorithm: 1*2+3*3+6*4=35 squares, O(20)
4141
42-
WA exp fit: 0.0451795e^(1.11088x)
43-
Rough upper bound: 0.045752e^(1.11088x)
44-
The estimates are really bad... exp model misses by like 4000
42+
WA exp fit: 0.0012656 e^(1.35537 x)
43+
The estimates are really bad... exp model misses by like 32k
4544
ppos size:
4645
3x3: 5
4746
4x4: 10
@@ -56,7 +55,7 @@ ppos size:
5655
13x13: 85555 (1.02s)
5756
14x14: 256366 (4.99s) (2 MiB)
5857
15x15: 829383 (25.81s) (6 MiB)
59-
16x16: est. 140s, 18 MiB
58+
16x16: 3317972 (4m20s using ./solver) (25.3 MiB)
6059
*/
6160

6261
int main(int argc, char const *argv[]) {

0 commit comments

Comments
 (0)