Understanding Set Field Value, Tag Field Value, and Cache Hits/Misses in MIPS Processor - caching

I am currently studying computer architecture and I am struggling with a specific exercise involving a 32-bit MIPS processor. The exercise asks to determine the set field value, tag field value, and if the instruction results in a cache hit or miss for each of the six assembly instructions given.
The instructions are as follows:
1 lw $t1,0x1040($0)
2 lw $t2,0x2044($0)
3 lw $t3,0x3048($0)
4 lw $t4,0x1044($0)
5 lw $t5,0x504c($0)
6 lw $t6,0x3040($0)
I am having trouble understanding how to calculate the set field value and tag field value, and then use that information to determine if there is a cache hit or miss.
If anyone could provide any guidance or clarification on this topic, I would greatly appreciate it. Thank you in advance for your help!
I have tried to understand the concept of set field value and tag field value in a cache memory and how to calculate them for a given address. I expected to be able to use that information to determine if there was a cache hit or miss. However, I am still struggling to fully grasp the concept and apply it to solve the given exercise.

Related

What's the acceptable range for reg_alpha and reg_lambda in H2O XGboost?

H2O document doesn't detail on these two hyper parameters. It only says these are L1 and L2 regularization parameters, with default values as 0 and 1. I can't find more info googling it either. Can someone provide any insight? TIA!
Alpha and lambda have no acceptable range. Usually, it depends on the problem you're trying to solve and the other parameters you're using, like max depth. The value for both typically ranges from 0 to 5, but it is not limited to that range.
I recommend you to take a look at this link: https://medium.com/data-design/xgboost-hi-im-gamma-what-can-i-do-for-you-and-the-tuning-of-regularization-a42ea17e6ab6
The idea is very clearly explained.

How to build bloom filter with size that can not fit in RAM?

Suppose we have to build a Bloom filter with 10^12 buckets on one machine with 32 GB RAM and a hard drive. Assume the keys are small and already on the hard drive. How could we build it in an efficient way?
My guess is to split Bloom filter into 4 parts (125GB / 4 fits into 32GB). Then pass through data 4 times each time hashing and updating corresponding slice in memory. Concatenate 4 slices back to get complete Bloom filter. Is this correct?
Why do you need so big filter ? Do you try to overestimate it in order to handle unbounded data as from a streaming source ? If yes, you can read about Stable Bloom filter and Scalable Bloom filter. Both are better adapted to such type of data than the classical Bloom filter.
To answer to your question, if you split your filter what you tell should work. But ensure that you deal with indexes correctly. If for instance the bit vector of 4 elements is splitted on 2 nodes, the first will be responsible for indexes (0, 1) and the second for (2, 3). You'll probably complicate it a little bit and store somewhere the mapping of what range is stored in what node and modify both reading and writing part accordingly.
You can also search for an example of implementation of so distributed Bloom filter. Maybe it'll give you another questioning points or, instead of developing your solution from scratch, you'll be able to test quickly how it behaves with your data pipeline.
In all cases, it would be great if you can give your short feedback here about how did you handled the problem and if you finally chosen another solution.

Tuning language weight (LW) and word insertion penalties (WIP) in CMU SPHINX

What is the right way to tune LW and WIP parameters of sphinx 3 and at what point do we stop tuning ?
I have been using these steps so far,
Since the decoder is much more sensitive to the LW, it is tuned first to get the highest word accuracy, using the default WIP of 0.7. And according to sphinx documentation LW has to be tuned between 6 and 13.
The WIP is now tuned keeping the above obtained LW until the insertions matches the deletions. At this point, the total number of decoded words will be equal to that of ground truth, which is expected out of an ideal decoder. And according to sphinx documentation WIP is supposed to be tuned in the range of 0.2 and 0.7
For my development data-set on finding the best LW of 10, I could never achieve insertions equal to deletions in 0.2 to 0.7 range of WIP. I reached this point only on using WIP of 2e22 ! Which is way out of the range.
As for such a high WIP, it should not be that high for sure. There are probably issues with your dataset, maybe you have a lot of silence there and it's better to tune silence probability for higher values otherwise it tries to match silence with words so you need more word insertion penalty to penalize those words. You always have an option to share your test set in order to get help on accuracy.

Yahtzee 3 of a Kind

Here is my situation, i am currently creating a Yahtzee game using Turbo Pascal Language in Lazarus IDE and i am up to the scoring side of the developement, i have already completed the Lower section of scoring and i have started the Higher section but i need some help writting a procedure to check for a three of a kind, my initial thought was to use an array and load the random numbers for the dice values and then use a loop function to check for 3 equal numbers but i'm not very confident in this area. Could i get some help ? I'm not asking for code, although it would be helpful, just a push in the right direction.
My dice integer value variables are, "Dice1" , "Dice2" , "Dice3" , "Dice4" , "Dice5" , "Dice6"
I think the conceptually simplest approach is to have an array of six counters - one for each possible value - that you initialize to zero and then loop over your dice array and increment the counters with each die's value.
You can then check if any of the counts becomes 3 (or more).
Or sort and then iterate to see if you have 3 same values in a row. The sorted array with dice values is also usable for the other detections like street, Carré (four of a kind), Yathzee etc.

Efficient mapping from 2^24 values to a 2^7 index

I have a data structure that stores amongst others a 24-bit wide value. I have a lot of these objects.
To minimize storage cost, I calculated the 2^7 most important values out of the 2^24 possible values and stored them in a static array. Thus I only have to save a 7-bit index to that array in my data structure.
The problem is: I get these 24-bit values and I have to convert them to my 7-bit index on the fly (no preprocessing possible). The computation is basically a search which one out of 2^7 values fits best. Obviously, this takes some time for a big number of objects.
An obvious solution would be to create a simple mapping array of bytes with the length 2^24. But this would take 16 MB of RAM. Too much.
One observation of the 16 MB array: On average 31 consecutive values are the same. Unfortunately there are also a number of consecutive values that are different.
How would you implement this conversion from a 24-bit value to a 7-bit index saving as much CPU and memory as possible?
Hard to say without knowing what the definition is of "best fit". Perhaps a kd-tree would allow a suitable search based on proximity by some metric or other, so that you quickly rule out most candidates, and only have to actually test a few of the 2^7 to see which is best?
This sounds similar to the problem that an image processor has when reducing to a smaller colour palette. I don't actually know what algorithms/structures are used for that, but I'm sure they're look-up-able, and might help.
As an idea...
Up the index table to 8 bits, then xor all 3 bytes of the 24 bit word into it.
then your table would consist of this 8 bit hash value, plus the index back to the original 24 bit value.
Since your data is RGB like, a more sophisticated hashing method may be needed.
bit24var & 0x000f gives you the right hand most char.
(bit24var >> 8) & 0x000f gives you the one beside it.
(bit24var >> 16) & 0x000f gives you the one beside that.
Yes, you are thinking correctly. It is quite likely that one or more of the 24 bit values will hash to the same index, due to the pigeon hole principal.
One method of resolving a hash clash is to use some sort of chaining.
Another idea would be to put your important values is a different array, then simply search it first. If you don't find an acceptable answer there, then you can, shudder, search the larger array.
How many 2^24 haves do you have? Can you sort these values and count them by counting the number of consecutive values.
Since you already know which of the 2^24 values you need to keep (i.e. the 2^7 values you have determined to be important), we can simply just filter incoming data and assign a value, starting from 0 and up to 2^7-1, to these values as we encounter them. Of course, we would need some way of keeping track of which of the important values we have already seen and assigned a label in [0,2^7) already. For that we can use some sort of tree or hashtable based dictionary implementation (e.g. std::map in C++, HashMap or TreeMap in Java, or dict in Python).
The code might look something like this (I'm using a much smaller range of values):
import random
def make_mapping(data, important):
mapping=dict() # dictionary to hold the final mapping
next_index=0 # the next free label that can be assigned to an incoming value
for elem in data:
if elem in important: #check that the element is important
if elem not in mapping: # check that this element hasn't been assigned a label yet
mapping[elem]=next_index
next_index+=1 # this label is assigned, the next new important value will get the next label
return mapping
if __name__=='__main__':
important_values=[1,5,200000,6,24,33]
data=range(0,300000)
random.shuffle(data)
answer=make_mapping(data,important_values)
print answer
You can make the search much faster by using hash/tree based set data structure for the set of important values. That would make the entire procedure O(n*log(k)) (or O(n) if its is a hashtable) where n is the size of input and k is the set of important values.
Another idea is to represent the 24BitValue array in a bit map. A nice unsigned char can hold 8 bits, so one would need 2^16 array elements. Thats 65536. If the corresponding bit is set, then you know that that specific 24BitValue is present in the array, and needs to be checked.
One would need an iterator, to walk through the array and find the next set bit. Some machines actually provide a "find first bit" operation in their instruction set.
Good luck on your quest.
Let us know how things turn out.
Evil.

Resources