User Tools

Site Tools


haas:fall2017:discrete:projects:pnc0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:fall2017:discrete:projects:pnc0 [2017/08/15 19:58] – [Revision List] wedgehaas:fall2017:discrete:projects:pnc0 [2017/10/15 21:11] (current) – [Programs] wedge
Line 3: Line 3:
 <WRAP><fs 150%>CSCS2330 Discrete Structures</fs></WRAP> <WRAP><fs 150%>CSCS2330 Discrete Structures</fs></WRAP>
 </WRAP> </WRAP>
- 
-~~TOC~~ 
  
 ======Project: ALGORITHMS - PRIME NUMBER CALCULATION (pnc0)====== ======Project: ALGORITHMS - PRIME NUMBER CALCULATION (pnc0)======
Line 19: Line 17:
     * 0.3: added new check/verify options to Makefile menu; checkqty, checkrange, verifyqty, verifyrange, verifyall. These will allow you to check to see if your programs are functioning within project specifications (20170714)     * 0.3: added new check/verify options to Makefile menu; checkqty, checkrange, verifyqty, verifyrange, verifyall. These will allow you to check to see if your programs are functioning within project specifications (20170714)
     * 0.4: added further explanation to "sqrt()-less square root approximation" section below, to clarify what I am asking for (20170815)     * 0.4: added further explanation to "sqrt()-less square root approximation" section below, to clarify what I am asking for (20170815)
 +    * 0.5: for increased readability, I've moved the information on the various "verifyall" tests below the sample output closer to the bottom of the project, and gave it its own unique section (20170830)
   * revision #: <description> (DATESTRING)   * revision #: <description> (DATESTRING)
  
Line 229: Line 228:
 It is your task to write the following prime number variants: It is your task to write the following prime number variants:
  
-  **primereg.c**: our baseline (does JUST the process, no optimizations) +  **primereg.c**: our baseline (does JUST the process, no optimizations) 
-  **primeregb.c**: tests specifically the break optimization +  **primeregb.c**: tests specifically the break optimization 
-  **primeregm.c**: tests specifically the map traversal +  **primeregm.c**: tests specifically the map traversal 
-  **primerego.c**: tests specifically the odd traversal +  **primerego.c**: tests specifically the odd traversal 
-  **primeregs.c**: tests specifically the square root trick (using sqrt()) +  **primeregs.c**: tests specifically the square root trick (using sqrt()) 
-  **primerega.c**: tests specifically the square root trick by approximating square root +  **primerega.c**: tests specifically the square root trick by approximating square root 
-  **primeregbm.c**: tests the break and map optimizations (together) +  **primeregbm.c**: tests the break and map optimizations (together) 
-  **primeregbo.c**: tests the break and odd optimizations (together) +  **primeregbo.c**: tests the break and odd optimizations (together) 
-  **primeregbs.c**: tests the break and sqrt() optimizations (together) +  **primeregbs.c**: tests the break and sqrt() optimizations (together) 
-  **primeregba.c**: tests the break and approximated square root optimizations (together)+  **primeregba.c**: tests the break and approximated square root optimizations (together)
  
 ====Program Specifications==== ====Program Specifications====
Line 355: Line 354:
  
 The various "verify" options do more aggressive checks, helping to ensure your project falls within stated project specifications. The various "verify" options do more aggressive checks, helping to ensure your project falls within stated project specifications.
- 
-The "verifyall" is an industrial grade verification; there are 13 specific tests performed, they are: 
-  * qtynorm: a normal quantity run (2-max) 
-    * ./primealg 2048 1 2 0 
-  * qtypart: an offset quantity run (24-max) 
-    * ./primealg 2048 1 24 0 
-  * rngnorm: a normal range run (2-max) 
-    * ./primealg 0 1 2 2048 
-  * rngpart: an offset range run (24-max) 
-    * ./primealg 0 1 24 2048 
-  * coop:    both qty and upper bounds set (q: 2048, ub: 8192) 
-    * ./primealg 2048 1 2 8192 
-  * coop2:   both qty and upper bounds set (q: 512, ub: 8192) 
-    * ./primealg 512 1 2 8192 
-  * coop3:   both qty and upper bounds set, offset start (24-max, q: 2048, ub: 8192) 
-    * ./primealg 2048 1 24 8192 
-  * noargs:  no arguments provided on command line (invokes error message) 
-    * ./primealg 
-  * invargs: insufficient number of arguments provided (invokes error) 
-    * ./primealg 128 
-  * invqty:  invalid value for quantity argument given (invokes error) 
-    * ./primealg -2 1 
-  * invnary: invalid value given for n-ary (invokes error) 
-    * ./primealg 128 2 
-  * invlow:  invalid value given for lower bound (invokes error) 
-    * ./primealg 128 1 1 
-  * invhigh: invalid value given for upper bound (invokes error) 
-    * ./primealg 128 1 32 24 
  
 Just another "nice thing" we deserve. Just another "nice thing" we deserve.
 =====Command-Line Arguments===== =====Command-Line Arguments=====
-To automate our comparisons, we will be making use of command-line arguments in our programs. As we have yet to really get into arrays, I will provide you some code that you can use that will allow you to utilize them for the purposes of this project.+To automate our comparisons, we will be making use of command-line arguments in our programs.
  
 ====header files==== ====header files====
Line 404: Line 375:
 int main(int argc, char **argv) int main(int argc, char **argv)
 </code> </code>
 +
 +There are two very important variables involved here (the types are actually what are important, the names given to the variables are actually quite, variable; you may see other references refer to them as things like "ac" and "av"):
 +
 +  * int argc: the count (an integer) of tokens given on the command line (program name + arguments)
 +  * <nowiki>char **argv</nowiki>: an array of strings (technically an array of an array of char) that contains "strings" of the various tokens provided on the command-line.
  
 The arguments are accessible via the argv array, in the order they were specified: The arguments are accessible via the argv array, in the order they were specified:
Line 412: Line 388:
   * argv[3]: conditionally optional; represents lower bound   * argv[3]: conditionally optional; represents lower bound
   * argv[4]: conditionally optional; represents upper bound   * argv[4]: conditionally optional; represents upper bound
 +
 +Additionally, let's not forget the **argc** variable, an integer, which contains a count of arguments (argc == argument count). If we provided argv[0] through argv[4], argc would contain a 5.
 +
 +===example===
 +For example, if we were to execute the **primereg** program:
 +
 +<cli>
 +lab46:~/src/discrete/pnc0$ ./primereg 128 1 2 2048
 +</cli>
 +
 +We'd have:
 +
 +  * <nowiki>argv[0]</nowiki>: "./primereg" 
 +  * <nowiki>argv[1]</nowiki>: "128" (note, NOT the scalar integer 128, but a string) 
 +  * <nowiki>argv[2]</nowiki>: "1"
 +  * <nowiki>argv[3]</nowiki>: "2" 
 +  * <nowiki>argv[4]</nowiki>: "2048" 
 +
 +and let's not forget:
 +
 +  * argc: 5   (there are 5 things, argv indexes 0, 1, 2, 3, and 4)
 +
 +With the conditionally optional arguments as part of the program spec, for a valid execution of the program, argc could be a value anywhere from 3 to 5.
  
 ====Simple argument checks==== ====Simple argument checks====
Line 727: Line 726:
 </cli> </cli>
  
 +===verifyall tests===
 +The "**verifyall**" is an industrial grade verification; there are 13 specific tests performed, they are:
 +  * **qtynorm**: a normal quantity run (2-max)
 +    * **./primealg 2048 1 2 0**
 +  * **qtypart**: an offset quantity run (24-max)
 +    * **./primealg 2048 1 24 0**
 +  * **rngnorm**: a normal range run (2-max)
 +    * **./primealg 0 1 2 2048**
 +  * **rngpart**: an offset range run (24-max)
 +    * **./primealg 0 1 24 2048**
 +  * **coop**: both qty and upper bounds set (q: 2048, ub: 8192)
 +    * **./primealg 2048 1 2 8192**
 +  * **coop2**: both qty and upper bounds set (q: 512, ub: 8192)
 +    * **./primealg 512 1 2 8192**
 +  * **coop3**: both qty and upper bounds set, offset start (24-max, q: 2048, ub: 8192)
 +    * **./primealg 2048 1 24 8192**
 +  * **noargs**:  no arguments provided on command line (invokes error message)
 +    * **./primealg**
 +  * **invargs**: insufficient number of arguments provided (invokes error)
 +    * **./primealg 128**
 +  * **invqty**: invalid value for quantity argument given (invokes error)
 +    * **./primealg -2 1**
 +  * **invnary**: invalid value given for n-ary (invokes error)
 +    * **./primealg 128 2**
 +  * **invlow**: invalid value given for lower bound (invokes error)
 +    * **./primealg 128 1 1**
 +  * **invhigh**: invalid value given for upper bound (invokes error)
 +    * **./primealg 128 1 32 24**
 +
 +If you'd actually to see the output your program's output is being tested against, that can be found in the **/usr/local/etc** directory in the file **primeTEST**, where "TEST" is the name of the verify test mentioned above.
 +
 +For example, if you wanted to see the intended output of the **invnary** test, that would be found in:
 +
 +  * **/usr/local/etc/primeinvnary**
 +
 +You could easily run your program with the stated arguments for the test, then use **cat** to display the test results and do a visual comparison.
 ====In general==== ====In general====
 Analyze the times you see... do they make sense, especially when comparing the algorithm used and the quantity being processed? These are related to some very important core Computer Science considerations we need to be increasingly mindful of as we design our programs and implement our solutions. Algorithmic complexity and algorithmic efficiency will be common themes in all we do. Analyze the times you see... do they make sense, especially when comparing the algorithm used and the quantity being processed? These are related to some very important core Computer Science considerations we need to be increasingly mindful of as we design our programs and implement our solutions. Algorithmic complexity and algorithmic efficiency will be common themes in all we do.
Line 788: Line 823:
  
 ====Evaluation Criteria==== ====Evaluation Criteria====
-What I will be looking for:+Grand total points:
  
 <code> <code>
 390:pnc0:final tally of results (390/390) 390:pnc0:final tally of results (390/390)
-*:pnc0:primereg.c performs proper argument checking [2/2] 
-*:pnc0:primereg.c performs proper bounds checking [2/2] 
-*:pnc0:primereg.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primereg.c implements only specified algorithm [6/6] 
-*:pnc0:primereg.c consistent indentation throughout code [2/2] 
-*:pnc0:primereg.c relevant comments throughout code [2/2] 
-*:pnc0:primereg.c code conforms to project specifications [3/3] 
-*:pnc0:primereg.c program output conforms to specifications [3/3] 
-*:pnc0:primereg.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primereg.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primereg.c make verifyall tests succeed [13/13] 
-*:pnc0:primerega.c performs proper argument checking [2/2] 
-*:pnc0:primerega.c performs proper bounds checking [2/2] 
-*:pnc0:primerega.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primerega.c implements only specified algorithm [6/6] 
-*:pnc0:primerega.c consistent indentation throughout code [2/2] 
-*:pnc0:primerega.c relevant comments throughout code [2/2] 
-*:pnc0:primerega.c code conforms to project specifications [3/3] 
-*:pnc0:primerega.c program output conforms to specifications [3/3] 
-*:pnc0:primerega.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primerega.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primerega.c make verifyall tests succeed [13/13] 
-*:pnc0:primeregb.c performs proper argument checking [2/2] 
-*:pnc0:primeregb.c performs proper bounds checking [2/2] 
-*:pnc0:primeregb.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primeregb.c implements only specified algorithm [6/6] 
-*:pnc0:primeregb.c consistent indentation throughout code [2/2] 
-*:pnc0:primeregb.c relevant comments throughout code [2/2] 
-*:pnc0:primeregb.c code conforms to project specifications [3/3] 
-*:pnc0:primeregb.c program output conforms to specifications [3/3] 
-*:pnc0:primeregb.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primeregb.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primeregb.c make verifyall tests succeed [13/13] 
-*:pnc0:primeregba.c performs proper argument checking [2/2] 
-*:pnc0:primeregba.c performs proper bounds checking [2/2] 
-*:pnc0:primeregba.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primeregba.c implements only specified algorithm [6/6] 
-*:pnc0:primeregba.c consistent indentation throughout code [2/2] 
-*:pnc0:primeregba.c relevant comments throughout code [2/2] 
-*:pnc0:primeregba.c code conforms to project specifications [3/3] 
-*:pnc0:primeregba.c program output conforms to specifications [3/3] 
-*:pnc0:primeregba.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primeregba.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primeregba.c make verifyall tests succeed [13/13] 
-*:pnc0:primeregbm.c performs proper argument checking [2/2] 
-*:pnc0:primeregbm.c performs proper bounds checking [2/2] 
-*:pnc0:primeregbm.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primeregbm.c implements only specified algorithm [6/6] 
-*:pnc0:primeregbm.c consistent indentation throughout code [2/2] 
-*:pnc0:primeregbm.c relevant comments throughout code [2/2] 
-*:pnc0:primeregbm.c code conforms to project specifications [3/3] 
-*:pnc0:primeregbm.c program output conforms to specifications [3/3] 
-*:pnc0:primeregbm.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primeregbm.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primeregbm.c make verifyall tests succeed [13/13] 
-*:pnc0:primeregbo.c performs proper argument checking [2/2] 
-*:pnc0:primeregbo.c performs proper bounds checking [2/2] 
-*:pnc0:primeregbo.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primeregbo.c implements only specified algorithm [6/6] 
-*:pnc0:primeregbo.c consistent indentation throughout code [2/2] 
-*:pnc0:primeregbo.c relevant comments throughout code [2/2] 
-*:pnc0:primeregbo.c code conforms to project specifications [3/3] 
-*:pnc0:primeregbo.c program output conforms to specifications [3/3] 
-*:pnc0:primeregbo.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primeregbo.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primeregbo.c make verifyall tests succeed [13/13] 
-*:pnc0:primeregbs.c performs proper argument checking [2/2] 
-*:pnc0:primeregbs.c performs proper bounds checking [2/2] 
-*:pnc0:primeregbs.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primeregbs.c implements only specified algorithm [6/6] 
-*:pnc0:primeregbs.c consistent indentation throughout code [2/2] 
-*:pnc0:primeregbs.c relevant comments throughout code [2/2] 
-*:pnc0:primeregbs.c code conforms to project specifications [3/3] 
-*:pnc0:primeregbs.c program output conforms to specifications [3/3] 
-*:pnc0:primeregbs.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primeregbs.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primeregbs.c make verifyall tests succeed [13/13] 
-*:pnc0:primeregm.c performs proper argument checking [2/2] 
-*:pnc0:primeregm.c performs proper bounds checking [2/2] 
-*:pnc0:primeregm.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primeregm.c implements only specified algorithm [6/6] 
-*:pnc0:primeregm.c consistent indentation throughout code [2/2] 
-*:pnc0:primeregm.c relevant comments throughout code [2/2] 
-*:pnc0:primeregm.c code conforms to project specifications [3/3] 
-*:pnc0:primeregm.c program output conforms to specifications [3/3] 
-*:pnc0:primeregm.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primeregm.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primeregm.c make verifyall tests succeed [13/13] 
-*:pnc0:primerego.c performs proper argument checking [2/2] 
-*:pnc0:primerego.c performs proper bounds checking [2/2] 
-*:pnc0:primerego.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primerego.c implements only specified algorithm [6/6] 
-*:pnc0:primerego.c consistent indentation throughout code [2/2] 
-*:pnc0:primerego.c relevant comments throughout code [2/2] 
-*:pnc0:primerego.c code conforms to project specifications [3/3] 
-*:pnc0:primerego.c program output conforms to specifications [3/3] 
-*:pnc0:primerego.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primerego.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primerego.c make verifyall tests succeed [13/13] 
-*:pnc0:primeregs.c performs proper argument checking [2/2] 
-*:pnc0:primeregs.c performs proper bounds checking [2/2] 
-*:pnc0:primeregs.c compiles cleanly, no compiler messages [2/2] 
-*:pnc0:primeregs.c implements only specified algorithm [6/6] 
-*:pnc0:primeregs.c consistent indentation throughout code [2/2] 
-*:pnc0:primeregs.c relevant comments throughout code [2/2] 
-*:pnc0:primeregs.c code conforms to project specifications [3/3] 
-*:pnc0:primeregs.c program output conforms to specifications [3/3] 
-*:pnc0:primeregs.c make checkqty runtimes within reason [2/2] 
-*:pnc0:primeregs.c make checkrange runtimes within reason [2/2] 
-*:pnc0:primeregs.c make verifyall tests succeed [13/13] 
 </code> </code>
 +
 +What I will be looking for (for each file):
 +
 +<code>
 +*:pnc0:primeALGO.c compiles cleanly, no compiler messages [3/3]
 +*:pnc0:primeALGO.c implements only specified algorithm [6/6]
 +*:pnc0:primeALGO.c consistent indentation throughout code [3/3]
 +*:pnc0:primeALGO.c relevant comments throughout code [3/3]
 +*:pnc0:primeALGO.c code conforms to project specifications [3/3]
 +*:pnc0:primeALGO.c runtime output conforms to specifications [4/4]
 +*:pnc0:primeALGO.c make checkqty test times within reason [2/2]
 +*:pnc0:primeALGO.c make checkrange test times within reason [2/2]
 +*:pnc0:primeALGO.c make verifyall tests succeed [13/13]
 +</code>
 +
 +As the optimizations improve upon others, some evaluations will be based upon differences between a baseline (in some cases, primereg) and the optimization.
haas/fall2017/discrete/projects/pnc0.1502827108.txt.gz · Last modified: 2017/08/15 19:58 by wedge