Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please read carefully before you answer! Ineed help with the C++ code. . The provided below sample MUST be used, or similar Sieve of Eratosthenes

Please read carefully before you answer!

Ineed help with the C++ code. . The provided below sample MUST be used, or similar Sieve of Eratosthenes piece of code.

If your code is not good for the exercise I don't need it and you will receive thumb down. Let only those who really wants to help to submit the solution. Thanks!

Complete the simulator and debug it

Create a cache class that can be configured for different sizes (up to at least 256KiB), associativities (direct mapped to 8-way set associative, and block sizes (from one byte to at least 64 bytes). For set-associative caches, the replacement policy should be LRU.

The only member function that is required for the cache is Cache.access(). This function should take on parameter (a byte address) and should simulate cache behavior as if the address was accessed. This includes updating cache state and returning TRUE if the access hit the cache, or FALSE if it did not. When the cache object is first created, all blocks in the cache should be marked as invalid.

Test the cache object using the provided trace files. After the entire trace file is run through the cache, the hit rates should match those provided. If your outputs do not match, spend more time debugging before proceeding. You will need a working simulator before proceeding.

Step III,IV - Gathering Data and Analysis

You will be instrumenting the Sieve of Eratosthenes algorithm by creating a cache object and "accessing it" using points from the actual data objects in the algorithm.

NOTE: Configure the Cache for a total of 256kiB, 8-way set associativity, and a 64 byte block size.

Your code should look something like this (all other variables we assume the compiler can assign to registers):

/* this code is based on the code from sieve of Erotosthenes at algolist.net http://www.algolist.net/Algorithms/Number_theoretic/Sieve_of_Eratosthenes */ unsigned long hits = 0; unsigned long accesses = 0; for (long m = 2; m <= upperBoundSquareRoot; m++) { // check for hit on read of isComposite[m] if (cache.access((unsigned long)(&(isComposite[m])))) hits++; accesses++; if (!isComposite[m]) { for (long k = m * m; k <= upperBound; k += m) { // check for hit on read of isComposite[k] if (cache.access((unsigned long)(&(isComposite[k])))) hits++; accesses++; isComposite[k] = true; // check for hit on write of isComposite[k] if (cache.access((unsigned long)(&(isComposite[k])))) hits++; accesses++; } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions