Table of Contents

Corning Community College

CSCS2650 Computer Organization

PROJECT: Prime Number Computation (PNC2)

OBJECTIVE

Continue exploring algorithm/implementation, this time exploring a new algorithm: the sieve of eratosthenes.

TASK

Add to your two separate, independent programs, one in Vircon32 C, and other in Vircon32 assembly, functionality that:

REFERENCE

The following are reference screenshots of what your implementations should approximate.

PNC2

Your next program, and first sieve, will be the Sieve of Eratosthenes. Perhaps among the best and likely longest-known sieves, its origins date from antiquity.

This sieve, instead of calculating to determine the eligibility of a prime, works in a manner of marking off patterns of values that cannot be prime (so, it is composite-focused in approach vs. prime-focused).

In order for it to work, we must store all the values we're processing so we can obtain what is left when done– what remains are the prime values.

Some refined considerations:

Here is the wikipedia page:

Here is an animated image of this sieve in action (from wikipedia):

EDIT

You will want to go here to edit and fill in the various sections of the document:

PNCX

algorithm: brute force / trial-by-division

variant: naive

The naive implementation is our baseline: implement with no awareness of potential tweaks, improvements, or optimizations. This should be the worst performing when compared to any optimization.

START TIMEKEEPING
NUMBER: FROM 2 THROUGH UPPERBOUND:
    ISPRIME <- YES
    FACTOR: FROM 2 THROUGH NUMBER-1:
        SHOULD FACTOR DIVIDE EVENLY INTO NUMBER:
            ISPRIME <- NO
    PROCEED TO NEXT FACTOR
    SHOULD ISPRIME STILL BE YES:
        INCREMENT OUR PRIME TALLY
PROCEED TO NEXT NUMBER
STOP TIMEKEEPING
Future Proofing
Printing Seconds

The amount of runtime a method takes can be measure in both cycle count and frame count. Since the cycle count resets every frame, frame count is needed for any time over 1/60th of a second

The Frame count can be added onto the cycle count to find a total time count. To do this the frame count needs to be multiplied by the number of cycles in a frame

Printing out the time can be separated into the whole portion and the fractional portion

The whole and fractional part can be found by dividing the cycle count by the amount of cycles in a unit of time (seconds for whole, milliseconds for fractional)

ADD FRAME TIME TO CYCLE TIME
DIVIDE THE CYCLE TIME BY THE CYCLES PER SECOND
PRINT THE WHOLE PORTION

MODULATE THE CYCLE TIME BY THE CYCLES PER SECOND
DIVIDE THE CYCLE TIME BY THE CYCLES PER MILLISECOND
   ADD ZEROS TO THE LEFT UNTIL STRING IS THE CORRECT LENGTH
PRINT THE FRACTIONAL PORTION
variant: break on composite (BOC)
variant: odds-only processing
variant: sqrt point
How to Sqrt
variant: break+odds
variant: break+sqrt
variant: break+odds+sqrt

ALGORITHM: sieve of eratosthenes

variant: baseline soe
START TIMEKEEPING
NUMBER: FROM 2 THROUGH UPPERBOUND:
    SHOULD THE NUMBER SLOT BE TRUE:
        VALUE AT NUMBER IS PRIME, INCREMENT TALLY
        MULTIPLE: FROM NUMBER+NUMBER THROUGH UPPERBOUND:
            VALUE AT MULTIPLE IS NOT PRIME
            MULTIPLE IS MULTIPLE PLUS NUMBER
        PROCEED TO NEXT MULTIPLE
    INCREMENT NUMBER
PROCEED TO NEXT NUMBER
STOP TIMEKEEPING
variant: sieve of eratosthenes with sqrt trick (soes)
START TIMEKEEPING
NUMBER: FROM 2 THROUGH NUMBER*NUMBER<UPPERBOUND:
    SHOULD THE NUMBER SLOT BE TRUE:
        VALUE AT NUMBER IS PRIME, INCREMENT TALLY
        MULTIPLE: FROM NUMBER*NUMBER THROUGH UPPERBOUND:
            VALUE AT MULTIPLE IS NOT PRIME
            MULTIPLE IS MULTIPLE PLUS NUMBER
        PROCEED TO NEXT MULTIPLE
    INCREMENT NUMBER
PROCEED TO NEXT NUMBER
STOP TIMEKEEPING

timing

Array in ASM

wedge pnc1 runtimes

Darkmoon pnc0 runtimes

Darkmoon pnc1 runtimes

Darkmoon pnc2 runtimes

TommyK pnc0 runtimes

TommyK pnc1 runtimes

TommyK pnc2 runtimes

BrandonD pnc0 runtimes

BrandonD pnc1 runtimes

 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

RUBRIC

I'll be evaluating the project based on the following criteria:

312:pnc2:final tally of results (312/312)
*:pnc2:submitted C and assembly implementations [26/26]
*:pnc2:each implementation builds cleanly [26/26]
*:pnc2:output conforms to specifications [26/26]
*:pnc2:processing is correct, and to specifications [26/26]
*:pnc2:working sieve of eratosthenes implementation [52/52]
*:pnc2:working soe with sqrt implementation [52/52]
*:pnc2:all variants and combinations thereof operational [26/26]
*:pnc2:graph produced from timing data produced [26/26]
*:pnc2:graph posted to discord and documentation page [26/26]
*:pnc2:timing data is taken out to at least 5 decimal places [26/26]

Pertaining to the collaborative authoring of project documentation

Additionally