team AllStuRead's repo
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

202 rader
8.0 KiB

2 månader sedan
  1. #####################################################################
  2. # CS:APP Data Lab
  3. # Directions to Instructors
  4. #
  5. # May 31, 2011: Now includes the "Beat the Prof" contest
  6. #
  7. # Copyright (c) 2002-2018, R. Bryant and D. O'Hallaron
  8. ######################################################################
  9. This directory contains the files that you will need to run the CS:APP
  10. Data Lab, which helps develops the student's understanding of bit
  11. representations, two's complement arithmetic, and IEEE floating point.
  12. For fun, we've also provided a new user-level HTTP-based "Beat the
  13. Prof" contest that replaces the old email-based version. The new
  14. contest is completely self-contained and does not require root
  15. password. The only requirement is that you have a user account on a
  16. Linux machine with an IP address.
  17. System requirements: Uses bison and flex to build dlc.
  18. ************
  19. 1. Overview
  20. ************
  21. In this lab, students work on a C file, called bits.c, that consists
  22. of a series of programming "puzzles". Each puzzle is an empty
  23. function body that must be completed so that it implements a specified
  24. mathematical function, such as "absolute value". Students must solve
  25. the non-floating point puzzles using only straight-line C code and a
  26. restricted set of C arithmetic and logical operators. For the
  27. floating-point puzzles they can use conditionals and arbitrary
  28. operators.
  29. Students use the following three tools to check their work.
  30. Instructors use the same tools to assign grades.
  31. 1. dlc: A "data lab compiler" that checks each function in bits.c for
  32. compliance with the coding guidelines, checking that the students use
  33. less than the maximum number of operators, that they use only
  34. straight-line code, and that they use only legal operators. The
  35. sources and a Linux binary are included with the lab.
  36. 2. btest: A test harness that checks the functions in bits.c for
  37. correctness. This tool has been significantly improved, now checking
  38. wide swaths around the edge cases for integers and floating point
  39. representations such as 0, Tmin, denorm-norm boundary, and inf.
  40. 3. driver.pl: A autograding driver program that uses dlc and btest to
  41. check each test function in bits.c for correctness and adherence to
  42. the coding guidelines
  43. The default version of the lab consists of 15 puzzles, in
  44. ./src/selections.c, chosen from a set of 73 standard puzzles defined
  45. in the directory ./src/puzzles/. You can customize the lab from term
  46. to term by choosing a different set of puzzles from the standard set
  47. of puzzles.
  48. You can also define new puzzles of your own and add them to the
  49. standard set. See ./src/README for instructions on how to add new
  50. puzzles to the standard set.
  51. NOTE: If you define new puzzles, please send them to me (Dave
  52. O'Hallaron, droh@cs.cmu.edu) so that I can add them to the standard
  53. set of puzzles in the data lab distribution.
  54. ********
  55. 2. Files
  56. ********
  57. All CS:APP labs have the same simple top-level directory structure:
  58. Makefile Builds the entire lab.
  59. README This file.
  60. src/ Contains all source files for the lab.
  61. datalab-handout/ Handout directory that goes to the students. Generated
  62. by the Makefile from files in ./src. Never modify anything
  63. in this directory.
  64. grade/ Autograding scripts that instructors can use to
  65. grade student handins.
  66. writeup/ Sample Latex lab writeup.
  67. contest/ Everything needed for the optional "Beat the Prof" contest.
  68. ********************
  69. 3. Building the Lab
  70. *******************
  71. Step 0. If you decide to run the "Beat the Prof" contest (section 5),
  72. then edit the ./contest/Contest.pm file so that the driver knows where
  73. to send the results. See ./contest/README for the simple
  74. instructions. If you decide *not* to offer the contest, then do
  75. nothing in this step.
  76. Step 1. Select the puzzles you want to include by editing the file
  77. ./src/selections.c.
  78. The default ./src/selections.c comes from a previous instance of the
  79. Data Lab at CMU. The file ./src/selections-all.c contains the
  80. complete list of puzzles to choose from.
  81. Step 2. Modify the Latex lab writeup in ./writeup/datalab.tex to
  82. tailor it for your course.
  83. Step 3. Type the following in the current directory:
  84. unix> make clean
  85. unix> make
  86. The Makefile generates the btest source files, builds the dlc binary
  87. (if necessary), formats the lab writeup, and then copies btest, the
  88. dlc binary, and the driver to the handout directory. After that, it
  89. builds a tarfile of the handout directory (in ./datalab-handout.tar)
  90. that you can then hand out to students.
  91. Note on Binary Portability: dlc is distributed in the datalab-handout
  92. directory as a binary. Linux binaries are not always portable across
  93. distributions due to different versions of dynamic libraries. You'll
  94. need to be careful to compile dlc on a machine that is compatible with
  95. those that the students will be using.
  96. Note: Running "make" also automatically generates the solutions to the
  97. puzzles, which you can find in ./src/bits.c and ./src/bits.c-solution.
  98. ******************
  99. 4. Grading the Lab
  100. ******************
  101. There is a handy autograder script that automatically grades your
  102. students' handins. See ./grade/README for instructions.
  103. **************************
  104. 5. "Beat the Prof" Contest
  105. **************************
  106. For fun, we've included an optional "Beat the Prof" contest, where
  107. students compete against themselves and the instructor. The goal is to
  108. solve each Data Lab puzzle using the fewest number of
  109. operators. Students who match or beat the instructor's operator count
  110. for each puzzle are winners. See ./contest/README for the simple
  111. instructions on how to set up the contest.
  112. NOTE: The contest is completely optional. Whether you decide to
  113. offer it or not has no affect on how you build and distribute the lab.
  114. NOTE: If you do decide to offer the contest, then you should configure
  115. the contest *before* you build the lab, so that the driver knows the
  116. server and port to send the contest results of each student (using the
  117. constants defined in the ./src/Driverhdrs.pm file, which is
  118. autogenerated from the ./contest/Contest.pm config file).
  119. If you decide to offer the contest *after* you've built and handed out
  120. the lab to the students, you're still OK:
  121. 1) Configure the contest as described in contest/Makefile
  122. 2) Rebuild the lab in the usual way:
  123. linux> cd datalab
  124. linux> make
  125. 3) Distribute the new ./src/Driverhdrs.pm file to the students.
  126. ***************************
  127. 6. Experimental BDD checker
  128. ***************************
  129. For fun, we have included an experimental correctness checker based on
  130. binary decision diagrams (BDDs) (R. E. Bryant, IEEE Transactions on
  131. Computers, August, 1986) that uses the CUDD BDD package from the
  132. University of Colorado. The BDD checker does an exhaustive test of the
  133. test functions in bits.c, formally verifying the correctness of each
  134. test function against a reference solution for *ALL* possible input
  135. values. For functions that differ from the reference solution, the BDD
  136. checker produces a counterexample in the form of a set of function
  137. arguments that cause the test solution to differ from the reference
  138. solution.
  139. The sources are included in ./src/bddcheck. To compile:
  140. unix> cd src/bddcheck
  141. unix> make clean
  142. unix> make
  143. To use BDDs to check ./src/bits.c for correctness:
  144. unix> cd src
  145. unix> ./bddcheck/check.pl # with error messages and counterexamples
  146. unix> ./bddcheck/check.pl -g # compact tabular output with no error messages
  147. Note that check.pl must be run from the parent directory of ./bddcheck.
  148. We've been using this BDD checker instead of btest at CMU for several
  149. years and the code appears to be stable. The main weakness is in the
  150. Perl code that extracts the functions from bits.c. It usually works,
  151. but some things -- such as calls to other functions, or functions that
  152. don't end with a single brace -- confuse it. So we're reluctant to
  153. make it the default checker for the distributed CS:APP labs. However,
  154. if you have any questions about the correctness of a particular
  155. solution, then this is the authoritative way to decide.
  156. Please send any comments about the BDD checker to randy.bryant@cs.cmu.edu.