Ejemplo n.º 1
0
        private void SegmentIORequestNoCache(IORequest currentRequest)
        {
            ulong lsn     = currentRequest.LSN;
            uint  reqSize = currentRequest.SizeInSubpages;

            uint subState = 0;
            uint handledSize = 0, subSize = 0;

            while (handledSize < reqSize)
            {
                lsn     = lsn % myFTL.AddressMapper.LargestLSN;
                subSize = myFTL.SubpageNoPerPage - (uint)(lsn % myFTL.SubpageNoPerPage);
                if (handledSize + subSize >= reqSize)
                {
                    subSize      = reqSize - handledSize;
                    handledSize += subSize;
                }
                ulong lpn = lsn / myFTL.SubpageNoPerPage;
                subState = myFTL.SetEntryState(lsn, subSize);
                createFlashOperationRequest(lpn, subSize, subState, currentRequest);
                lsn          = lsn + subSize;
                handledSize += subSize;
            }

            if (currentRequest.InternalRequestList.Count == 0)
            {
                myHI.SendEarlyResponseToHost(currentRequest);
            }

            /*try to estimate the execution time of each flash transaction separately*/
            foreach (InternalRequest ir in currentRequest.InternalRequestList)
            {
                uint queueID = ir.TargetPageAddress.ChannelID;
                if (queueID == uint.MaxValue)
                {
                    throw new Exception("Current implementation does not support dynamic channel allocation!");
                }
            }
        }
        public override void Preprocess()
        {
            loggingStep = numberOfRequestsToBeSeen / totalLinesInLogfile;
            if (loggingStep == 0)
            {
                loggingStep = 1;
            }

            uint[] State = new uint[FTL.AddressMapper.AddressMappingDomains[AddressMappingModule.DefaultStreamID].TotalPagesNo];
            for (uint i = 0; i < FTL.AddressMapper.AddressMappingDomains[AddressMappingModule.DefaultStreamID].TotalPagesNo; i++)
            {
                State[i] = 0;
            }

            Console.WriteLine("\n");
            Console.WriteLine(".................................................\n");
            Console.WriteLine("Preprocess started\n");

            ulong reqCntr = 0;
            ulong lsn = 0;
            uint  reqSize = 0, sub_size, add_size;
            uint  streamID = 0;

            while (reqCntr < numberOfRequestsToBeSeen)
            {
                #region RequestGeneration
                reqCntr++;
                switch (addressDistributionType)
                {
                case InputStreamSynthetic.DistributionType.Uniform:
                    lsn = randomAddressGenerator1.UniformULong(addressDistributionParam1, addressDistributionParam2);
                    break;

                case InputStreamSynthetic.DistributionType.Normal:
                    double templsn = randomAddressGenerator1.Normal(addressDistributionParam1, addressDistributionParam2);
                    lsn = (ulong)templsn;
                    if (templsn < 0)
                    {
                        lsn = 0;
                    }
                    else if (templsn > this.FTL.AddressMapper.LargestLSN)
                    {
                        lsn = this.FTL.AddressMapper.LargestLSN;
                    }
                    break;

                case InputStreamSynthetic.DistributionType.Fixed:
                    lsn = addressDistributionParam1;
                    break;

                case InputStreamSynthetic.DistributionType.HotCold:
                    if (randomHotColdRatioGenerator.Uniform(0, 1) < hotTrafficRate)
                    {
                        lsn = addressDistributionParam1 + randomHotAddressGenerator.UniformULong(0, hotAddressRange);
                    }
                    else
                    {
                        lsn = randomAddressGenerator1.UniformULong(0, this.FTL.AddressMapper.LargestLSN - hotAddressRange);
                        if (lsn > addressDistributionParam1)
                        {
                            lsn += hotAddressRange;
                        }
                    }
                    break;

                default:
                    throw new Exception("Unknown distribution type for address.");
                }

                switch (requestSizeDistributionType)
                {
                case InputStreamSynthetic.DistributionType.Uniform:
                    double tempReqSize = randomRequestSizeGenerator.Uniform(requestSizeDistributionParam1B, requestSizeDistributionParam2B);
                    reqSize = (uint)(Math.Ceiling(tempReqSize / (double)FTL.SubPageCapacity));
                    if (reqSize == 0)
                    {
                        reqSize = 1;
                    }
                    break;

                case InputStreamSynthetic.DistributionType.Normal:
                    tempReqSize = randomRequestSizeGenerator.Normal(requestSizeDistributionParam1B, requestSizeDistributionParam2B);
                    reqSize     = (uint)(Math.Ceiling(tempReqSize / (double)FTL.SubPageCapacity));
                    if (tempReqSize < 0)
                    {
                        reqSize = 1;
                    }
                    break;

                case InputStreamSynthetic.DistributionType.Fixed:
                    reqSize = (uint)(Math.Ceiling(requestSizeDistributionParam1B / (double)FTL.SubPageCapacity));
                    break;

                default:
                    throw new Exception("Uknown distribution type for requset size.");
                }
                #endregion

                add_size = 0;
                if (randomRequestTypeGenerator.Uniform(0, 1) < readRatio)//read request
                {
                    while (add_size < reqSize)
                    {
                        lsn      = lsn % this.FTL.AddressMapper.LargestLSN;
                        sub_size = FTL.SubpageNoPerPage - (uint)(lsn % FTL.SubpageNoPerPage);
                        if (add_size + sub_size >= reqSize)
                        {
                            sub_size  = reqSize - add_size;
                            add_size += sub_size;
                        }

                        if ((sub_size > FTL.SubpageNoPerPage) || (add_size > reqSize))
                        {
                            Console.WriteLine("preprocess sub_size:{0}\n", sub_size);
                        }
                        ulong lpn = lsn / FTL.SubpageNoPerPage;

                        if (State[lpn] == 0)
                        {
                            State[lpn] = FTL.SetEntryState(lsn, sub_size);
                            FTL.HandleMissingReadAccessTarget(lsn, State[lpn]);
                        }
                        else //if (State[lpn] > 0)
                        {
                            uint map_entry_new = FTL.SetEntryState(lsn, sub_size);
                            uint map_entry_old = State[lpn];
                            uint modify_temp   = map_entry_new | map_entry_old;
                            State[lpn] = modify_temp;

                            if (((map_entry_new ^ map_entry_old) & map_entry_new) != 0)
                            {
                                uint map_entry_old_real_map = FTL.AddressMapper.AddressMappingDomains[AddressMappingModule.DefaultStreamID].MappingTable.State[lpn];
                                uint modify_real_map        = ((map_entry_new ^ map_entry_old) & map_entry_new) | map_entry_old_real_map;
                                if (FTL.AddressMapper.AddressMappingDomains[AddressMappingModule.DefaultStreamID].MappingTable.State[lpn] == 0)
                                {
                                    FTL.HandleMissingReadAccessTarget(lsn, modify_real_map);
                                }
                                else
                                {
                                    FTL.ModifyPageTableStateforMissingRead(lpn, modify_real_map);
                                }
                            }
                        }//else if(Controller.DRAM.Map.Entry[lpn].state>0)

                        lsn       = lsn + sub_size;
                        add_size += sub_size;
                    }//while(add_size<size)
                }
                else
                {
                    while (add_size < reqSize)
                    {
                        lsn      = lsn % this.FTL.AddressMapper.LargestLSN;
                        sub_size = FTL.SubpageNoPerPage - (uint)(lsn % FTL.SubpageNoPerPage);
                        if (add_size + sub_size >= reqSize)
                        {
                            sub_size  = reqSize - add_size;
                            add_size += sub_size;
                        }

                        if ((sub_size > FTL.SubpageNoPerPage) || (add_size > reqSize))
                        {
                            Console.WriteLine("preprocess sub_size:{0}\n", sub_size);
                        }

                        ulong lpn = lsn / FTL.SubpageNoPerPage;
                        if (State[lpn] == 0)
                        {
                            State[lpn] = FTL.SetEntryState(lsn, sub_size);   //0001
                        }
                        else
                        {
                            uint map_entry_new = FTL.SetEntryState(lsn, sub_size);
                            uint map_entry_old = FTL.AddressMapper.AddressMappingDomains[streamID].MappingTable.State[lpn];
                            uint modify        = map_entry_new | map_entry_old;
                            State[lpn] = modify;
                        }
                        lsn       = lsn + sub_size;
                        add_size += sub_size;
                    }
                }
            }
            randomRequestSizeGenerator  = new RandomGenerator(requestSizeGenerationSeed);
            randomRequestTypeGenerator  = new RandomGenerator(requestTypeGenerationSeed);
            randomAddressGenerator1     = new RandomGenerator(addressGenerationSeed1);
            randomHotColdRatioGenerator = new RandomGenerator(addressGenerationSeed2);
            randomHotAddressGenerator   = new RandomGenerator(addressGenerationSeed3);
            Console.WriteLine("Preprocess complete!\n");
            Console.WriteLine(".................................................\n");
        }