Exemplo n.º 1
0
        /// <summary>
        /// Processor Construction Function
        /// </summary>
        /// <param name="insp_"> Shared Instruction Partitioner </param>
        /// <param name="pid_"> Processor ID</param>
        public PIMProc(ref InsPartition insp_, int pid_)
        {
            pid     = pid_;
            ins_p   = insp_;
            L1Cache = new Cache(true);
            //  Shared_Cache = new Cache(config, true);
            ins_w = new InstructionWindow(Config.ins_w_size, pid);

            IPC = PIMConfigs.IPC;
            if (PIMConfigs.use_l1_cache)
            {
                cache_req_queue = new Queue <ProcRequest>();
            }
            MSHR         = new List <ProcRequest>(Config.mshr_size);
            cal_restrict = new Counter(Config.IPC, Config.IPC);
            mem_restrict = new Counter(1, 1);
            alu          = new ALU();
            tlb          = new PageConverter();
            if (PIMConfigs.writeback)
            {
                writeback_req = new List <ProcRequest>();
            }
            //init callback
            read_callback  = new ReadCallBack(handle_read_callback);
            write_callback = new WriteCallBack(handle_write_callback);
        }
Exemplo n.º 2
0
        public async Task <PageDto> GetPageByIdAsync(Guid id)
        {
            PageDto page = PageConverter.Convert(await _pageRepo.GetByIdAsync(id));

            page.Blocks     = BlockConverter.Convert(await _blockRepo.GetByPageIdAsync(id));
            page.CourseName = _courseRepo.GetByIdAsync(page.CourseId).Result.Name;
            return(page);
        }
Exemplo n.º 3
0
        public async Task <CourseDto> GetCourseByIdAsync(Guid id)
        {
            CourseDto course = CourseConverter.Convert(await _courseRepo.GetByIdAsync(id));

            course.DirectionName = _directionRepo.GetByIdAsync(course.DirectionId).Result.Name;
            course.Groups        = GroupConverter.Convert(await _groupRepo.GetByCourseIdAsync(id));
            course.Pages         = PageConverter.Convert(await _pageRepo.GetByCourseIdAsync(id));
            return(course);
        }
Exemplo n.º 4
0
        private void ProcessPages(string exhibitId, CancellationToken token, ITransactionDataAccess dataAccess,
                                  Dictionary <MediaDto, string> mediaToFilePath)
        {
            var fetchedMedia = mediaDataFetcher.CombineMediasAndFiles(dataAccess, mediaToFilePath);

            if (token.IsCancellationRequested)
            {
                return;
            }

            var exhibit = dataAccess.Exhibits().GetExhibit(exhibitId);

            foreach (var pageDto in pageItems)
            {
                var dbPage = PageConverter.Convert(pageDto);

                AddContentToPage(dbPage, pageDto, fetchedMedia);
                // Add Page with content to the exhibit
                exhibit.Pages.Add(dbPage);
            }

            // Rearrange additional information pages
            var pagesToBeRemoved = new List <Page>();

            foreach (var pageDto in pageItems)
            {
                if (pageDto.AdditionalInformationPages.Count > 0)
                {
                    foreach (var existingPageWithInfo in exhibit.Pages)
                    {
                        if (pageDto.Id == existingPageWithInfo.IdForRestApi)
                        {
                            foreach (var pageId in pageDto.AdditionalInformationPages)
                            {
                                foreach (var pageToBeAdded in exhibit.Pages)
                                {
                                    if (pageToBeAdded.IdForRestApi == pageId)
                                    {
                                        existingPageWithInfo.AdditionalInformationPages.Add(pageToBeAdded);
                                        pagesToBeRemoved.Add(pageToBeAdded);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            foreach (var pageToBeRemoved in pagesToBeRemoved)
            {
                exhibit.Pages.Remove(pageToBeRemoved);
            }

            exhibit.DetailsDataLoaded = true;
        }
Exemplo n.º 5
0
        public byte[] Save()
        {
            foreach (var page in pages)
            {
                var isLastPage = page == pages.Last();
                document.MainDocumentPart.Document.Body.Append(PageConverter.Convert(page, this, document, isLastPage));
            }

            using (memoryStream)
                using (document)
                    document.Close();
            return(memoryStream.ToArray());
        }
Exemplo n.º 6
0
        private void AddContentToPage(Page dbPage, PageDto pageDto, FetchedMediaData fetchedMedia)
        {
            if (pageDto != null && dbPage != null)
            {
                PageConverter.Convert(pageDto, dbPage);

                switch (dbPage)
                {
                case ImagePage imagePage:
                    var image = fetchedMedia.Images.SingleOrDefault(x => x.IdForRestApi == pageDto.Image);
                    imagePage.Image = image ?? BackupData.BackupImage;
                    break;

                case TextPage textPage:
                    break;

                case TimeSliderPage timeSliderPage:
                    var fetchedImages = fetchedMedia.Images;

                    if (fetchedImages.Count > 0)
                    {
                        Debug2.Assert(timeSliderPage.SliderImages.Count == pageDto.Images.Count);
                        for (var i = 0; i < timeSliderPage.SliderImages.Count; i++)
                        {
                            var imageId = pageDto.Images[i].Image;
                            var dbImage = fetchedImages.FirstOrDefault(img => img.IdForRestApi == imageId);
                            timeSliderPage.SliderImages[i].Image = dbImage;
                        }
                    }
                    else
                    {
                        timeSliderPage.SliderImages.Add(new TimeSliderPageImage
                        {
                            Page  = timeSliderPage,
                            Image = BackupData.BackupImage
                        });
                    }

                    break;
                }

                var audio = fetchedMedia.Audios.SingleOrDefault(x => x.IdForRestApi == pageDto.Audio);

                if (audio != null)
                {
                    dbPage.Audio = audio;
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Add TLB to Proc.
 /// Used when shared TLB.
 /// </summary>
 /// <param name="tlb_">Linked TLB</param>
 public void attach_tlb(ref PageConverter tlb_)
 {
     this.tlb = tlb_;
 }
Exemplo n.º 8
0
 public async Task <bool> UpdatePageAsync(PageDto item)
 {
     return(await _pageRepo.UpdateAsync(PageConverter.Convert(item)));
 }
Exemplo n.º 9
0
 public async Task <PageDto> CreatePageAsync(PageDto item)
 {
     return(PageConverter.Convert(await _pageRepo.CreateAsync(PageConverter.Convert(item))));
 }
Exemplo n.º 10
0
 public async Task <List <PageDto> > GetPageByCourseIdAsync(Guid id)
 {
     return(PageConverter.Convert(await _pageRepo.GetByCourseIdAsync(id)));
 }
Exemplo n.º 11
0
 public async Task <List <PageDto> > GetAllPageAsync()
 {
     return(PageConverter.Convert(await _pageRepo.GetAllAsync()));
 }
Exemplo n.º 12
0
        public PIMSimulator(string[] args)
        {
            initAllconfigs(args);
            trace = new TraceFetcher();


            ins_p = new InsPartition();

            pg = new PageConverter();

            if (Config.shared_cache)
            {
                shared_cache = new Shared_Cache();
            }
            proc = new List <Proc>();

            for (int i = 0; i < Config.N; i++)
            {
                Proc to_add = new Proc(ref ins_p, i);
                if (Config.shared_cache)
                {
                    to_add.attach_shared_cache(ref shared_cache);
                }
                to_add.attach_tlb(ref pg);
                proc.Add(to_add);
            }
            int count = 0;

            foreach (var item in Config.memory)
            {
                if (item.Key.Equals("HMC"))
                {
                    var tp = new HMCMem(count++) as MemObject;
                    MemorySelector.add(item.Value, ref tp);
                }
                else
                {
                    if (item.Key.Equals("DRAM") || item.Key.Equals("PCM"))
                    {
                        var tp = new DDRMem(count++) as MemObject;
                        MemorySelector.add(item.Value, ref tp);
                    }
                    else
                    {
                        //error
                        DEBUG.Error("Unknown Memory Type.");
                        Environment.Exit(3);
                    }
                }
            }

            Mctrl.init_queue();

            PIMMctrl.init_queue();


            pim = new PIM.PIM(ref ins_p);
            Coherence.init();
            Coherence.linkproc(proc);
            GlobalTimer.InitClock();
            BuildTopology();
        }