void GLTexture::TexImage2D(GLenum int_format, int2 size, GLenum format, GLenum type, const void *data) { m_format = int_format; if (!m_texname) { glGenTextures(1, &m_texname); } else { gpuMemoryUsed -= m_texsize.x * m_texsize.y * textureFormatBytesPerPixel(m_format); } glBindTexture(GL_TEXTURE_2D, m_texname); #if OPENGL_ES m_texsize = float2(roundUpPower2(size.x), roundUpPower2(size.y)); glTexImage2D(GL_TEXTURE_2D, 0, format, m_texsize.x, m_texsize.y, 0, format, GL_UNSIGNED_BYTE, data); glReportError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #else m_texsize = float2(size); glTexImage2D(GL_TEXTURE_2D, 0, m_format, size.x, size.y, 0, format, type, data); glReportError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE_SGIS); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE_SGIS); #endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D, 0); m_size = float2(size); gpuMemoryUsed += m_texsize.x * m_texsize.y * textureFormatBytesPerPixel(m_format); }
FullMSHR<Addr_t, Cache_t>::FullMSHR(const char *name, int size, int lineSize, int aPolicy) : MSHR<Addr_t, Cache_t>(name, size, lineSize, aPolicy) ,nStallConflict("%s_MSHR:nStallConflict", name) ,MSHRSize(roundUpPower2(size)*4) ,MSHRMask(MSHRSize-1) { I(lineSize>=0 && Log2LineSize<(8*sizeof(Addr_t)-1)); overflowing = false; entry = new EntryType[MSHRSize]; for(int i=0;i<MSHRSize;i++) { entry[i].inUse = false; I(entry[i].cc.empty()); } }
void processorCore() { const char *proc = SescConf->getCharPtr("","cpusimu",0) ; fprintf(stderr,"proc = [%s]\n",proc); xcacti_flp xflp; //---------------------------------------------- // Branch Predictor processBranch(proc); //---------------------------------------------- // Register File int issueWidth= SescConf->getInt(proc,"issueWidth"); int size = SescConf->getInt(proc,"intRegs"); int banks = 1; int rdPorts = 2*issueWidth; int wrPorts = issueWidth; int bits = 32; int bytes = 8; if(SescConf->checkInt(proc,"bits")) { bits = SescConf->getInt(proc,"bits"); bytes = bits/8; if (bits*8 != bytes) { fprintf(stderr,"Not valid number of bits for the processor core [%d]\n",bits); exit(-2); } } if(SescConf->checkInt(proc,"intRegBanks")) banks = SescConf->getInt(proc,"intRegBanks"); if(SescConf->checkInt(proc,"intRegRdPorts")) rdPorts = SescConf->getInt(proc,"intRegRdPorts"); if(SescConf->checkInt(proc,"intRegWrPorts")) wrPorts = SescConf->getInt(proc,"intRegWrPorts"); double regEnergy = getEnergy(size*bytes, bytes, 1, rdPorts, wrPorts, banks, 0, bits, &xflp); printf("\nRegister [%d bytes] banks[%d] ports[%d] Energy[%g]\n" ,size*bytes, banks, rdPorts+wrPorts, regEnergy); #ifdef ESESC_ESESCTHERM2 const char *blockName = SescConf->getCharPtr(proc,"IntRegBlockName"); I(blockName); update_layout(blockName, &xflp); blockName = SescConf->getCharPtr(proc,"fpRegBlockName"); I(blockName); update_layout(blockName , &xflp); // FIXME: different energy for FP register #else SescConf->updateRecord(proc,"wrRegEnergy",regEnergy); SescConf->updateRecord(proc,"rdRegEnergy",regEnergy); #endif //---------------------------------------------- // Load/Store Queue size = SescConf->getInt(proc,"maxLoads"); banks = 1; rdPorts = res_memport; wrPorts = res_memport; if(SescConf->checkInt(proc,"lsqBanks")) banks = SescConf->getInt(proc,"lsqBanks"); regEnergy = getEnergy(size*2*bytes,2*bytes,size,rdPorts,wrPorts,banks,1, 2*bits, &xflp); #ifdef ESESC_ESESCTHERM2 // FIXME: partition energies per structure blockName = SescConf->getCharPtr(proc,"LSQBlockName"); I(blockName); update_layout(lsqBlockName, &xflp); #else SescConf->updateRecord(proc,"ldqRdWrEnergy",regEnergy); #endif printf("\nLoad Queue [%d bytes] banks[%d] ports[%d] Energy[%g]\n" ,size*2*bytes, banks, 2*res_memport, regEnergy); size = SescConf->getInt(proc,"maxStores"); regEnergy = getEnergy(size*4*bytes,4*bytes,size,rdPorts,wrPorts,banks,1, 2*bits, &xflp); #ifdef ESESC_ESESCTHERM2 // FIXME: partition energies per structure blockName = SescConf->getCharPtr(proc,"LSQBlockName"); I(blockName); update_layout(lsqBlockName, &xflp); #else SescConf->updateRecord(proc,"stqRdWrEnergy",regEnergy); #endif printf("\nStore Queue [%d bytes] banks[%d] ports[%d] Energy[%g]\n" ,size*4*bytes, banks, 2*res_memport, regEnergy); #ifdef ESESC_INORDER size = size/4; regEnergy = getEnergy(size*4*bytes,4*bytes,size,rdPorts,wrPorts,banks,1, 2*bits, &xflp); printf("\nStore Inorder Queue [%d bytes] banks[%d] ports[%d] Energy[%g]\n" ,size*4*bytes, banks, 2*res_memport, regEnergy); SescConf->updateRecord(proc,"stqRdWrEnergyInOrder",regEnergy); #ifdef ESESC_ESESCTHERM I(0); exit(-1); // Not supported #endif #endif //---------------------------------------------- // Reorder Buffer size = SescConf->getInt(proc,"robSize"); banks = size/64; if (banks == 0) { banks = 1; }else{ banks = roundUpPower2(banks); } // Retirement should hit another bank rdPorts = 1; // continuous possitions wrPorts = 1; regEnergy = getEnergy(size*2,2*issueWidth,1,rdPorts,wrPorts,banks,0,16*issueWidth, &xflp); #ifdef ESESC_ESESCTHERM2 const char *blockName = SescConf->getCharPtr(proc,"robBlockName"); I(blockName); update_layout(blockName, &xflp); // FIXME: partition energies per structure #else SescConf->updateRecord(proc,"robEnergy",regEnergy); #endif printf("\nROB [%d bytes] banks[%d] ports[%d] Energy[%g]\n",size*2, banks, 2*rdPorts, regEnergy); //---------------------------------------------- // Rename Table { double bitsPerEntry = log((double)SescConf->getInt(proc,"intRegs"))/log((double)2); size = roundUpPower2(static_cast<unsigned int>(32*bitsPerEntry/8)); banks = 1; rdPorts = 2*issueWidth; wrPorts = issueWidth; regEnergy = getEnergy(size,1,1,rdPorts,wrPorts,banks,0,1, &xflp); #ifdef ESESC_ESESCTHERM2 update_layout("IntRAT", &xflp); //FIXME: create a IntRATblockName // FIXME: partition energies per structure #endif printf("\nrename [%d bytes] banks[%d] Energy[%g]\n",size, banks, regEnergy); regEnergy += getEnergy(size,1,1,rdPorts/2+1,wrPorts/2+1,banks,0,1, &xflp); #ifdef ESESC_ESESCTHERM2 update_layout("IntRAT", &xflp); // FIXME: partition energies per structure #else // unified FP+Int RAT energy counter SescConf->updateRecord(proc,"renameEnergy",regEnergy); #endif } //---------------------------------------------- // Window Energy & Window + DDIS { int min = SescConf->getRecordMin(proc,"cluster") ; int max = SescConf->getRecordMax(proc,"cluster") ; I(min==0); for(int i = min ; i <= max ; i++) { const char *cluster = SescConf->getCharPtr(proc,"cluster",i) ; // TRADITIONAL COLLAPSING ISSUE LOGIC // Recalculate windowRdWrEnergy using CACTI (keep select and wake) size = SescConf->getInt(cluster,"winSize"); banks = 1; rdPorts = SescConf->getInt(cluster,"wakeUpNumPorts"); wrPorts = issueWidth; int robSize = SescConf->getInt(proc,"robSize"); float entryBits = 4*(log((double )robSize)/log((double)2)); // src1, src2, dest, instID entryBits += 7; // opcode entryBits += 1; // ready bit int tableBits = static_cast<int>(entryBits * size); int tableBytes; if (tableBits < 8) { tableBits = 8; tableBytes = 1; }else{ tableBytes = tableBits/8; } int assoc= roundUpPower2(static_cast<unsigned int>(entryBits/8)); tableBytes = roundUpPower2(tableBytes); regEnergy = getEnergy(tableBytes,tableBytes/assoc,assoc,rdPorts,wrPorts,banks,1,static_cast<int>(entryBits), &xflp); printf("\nWindow [%d bytes] assoc[%d] banks[%d] ports[%d] Energy[%g]\n" ,tableBytes, assoc, banks, rdPorts+wrPorts, regEnergy); #ifdef ESESC_ESESCTHERM2 const char *blockName = SescConf->getCharPtr(cluster,"blockName"); I(blockName); update_layout(blockName, &xflp); #else // unified FP+Int RAT energy counter SescConf->updateRecord(cluster,"windowRdWrEnergy" ,regEnergy,0); #endif } } }
double getEnergy(int size ,int bsize ,int assoc ,int rdPorts ,int wrPorts ,int subBanks ,int useTag ,int bits ,xcacti_flp *xflp ) { int nsets = size/(bsize*assoc); int fully_assoc, associativity; int rwPorts = 0; if (nsets == 0) { printf("Invalid cache parameters size[%d], bsize[%d], assoc[%d]\n", size, bsize, assoc); exit(0); } if (subBanks == 0) { printf("Invalid cache subbanks parameters\n"); exit(0); } if ((size/subBanks)<64) { printf("size %d: subBanks %d: assoc %d : nset %d\n",size,subBanks,assoc,nsets); size =64*subBanks; } if (rdPorts>1) { wrPorts = rdPorts-2; rdPorts = 2; } if ((rdPorts+wrPorts+rwPorts) < 1) { rdPorts = 0; wrPorts = 0; rwPorts = 1; } if (bsize*8 < bits) bsize = bits/8; BITOUT = bits; if (size == bsize * assoc) { fully_assoc = 1; }else{ fully_assoc = 0; } size = roundUpPower2(size); if (fully_assoc) { associativity = size/bsize; }else{ associativity = assoc; } if (associativity >= 32) associativity = size/bsize; nsets = size/(bsize*associativity); total_result_type result2; printf("\n\n\n########################################################"); printf("\nInput to Cacti_Interface..."); printf("\n size = %d, bsize = %d, assoc = %d, rports = %d, wports = %d", size, bsize, associativity, rdPorts, wrPorts); printf("\n subBanks = %d, tech = %f, bits = %d", subBanks, tech, bits); result2 = cacti_interface(size, bsize, associativity, rwPorts, rdPorts, wrPorts, 0, subBanks, tech, bits, 0, 0, // custom tag 0, useTag); #ifdef DEBUG //output_data(&result,&arearesult,&arearesult_subbanked,¶meters); output_data(&result2.result,&result2.area,&result2.params); #endif //xcacti_power_flp(&result,&arearesult,&arearesult_subbanked,¶meters, xflp); xcacti_power_flp(&result2.result, &result2.area, &result2.arearesult_subbanked, &result2.params, xflp); //return wattch2cactiFactor * 1e9*(result.total_power_without_routing/subBanks + result.total_routing_power); // return wattch2cactiFactor * 1e9*(result2.result.total_power_without_routing.readOp.dynamic / subBanks + // result2.result.total_routing_power.readOp.dynamic); return cacti2wattchFactor * 1e9*(result2.result.total_power_without_routing.readOp.dynamic / subBanks + result2.result.total_routing_power.readOp.dynamic); }
void GLRenderTexture::Generate(ZFlags zflags) { ASSERT_MAIN_THREAD(); ASSERT(m_size.x >= 1 && m_size.y >= 1); GLsizei width = m_size.x; GLsizei height = m_size.y; #if OPENGL_ES // textures must be a power of 2 on ios width = roundUpPower2(width); height = roundUpPower2(height); #endif if (s_defaultFramebuffer < 0) { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &s_defaultFramebuffer); } m_texsize = float2(width, height); DPRINT(SHADER, ("Generating render texture, %dx%d %s %s", width, height, textureFormatToString(m_format), (zflags&HASZ) ? "Z16" : "No_Z")); glReportError(); glGenFramebuffers(1, &m_fbname); glReportError(); glGenTextures(1, &m_texname); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_texname); glReportError(); #if OPENGL_ES if (m_format == GL_RGBA16F_ARB) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_HALF_FLOAT_OES, 0); } else #endif { glTexImage2D(GL_TEXTURE_2D, 0, m_format, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); } glReportError(); gpuMemoryUsed += width * height * textureFormatBytesPerPixel(m_format); glBindFramebuffer(GL_FRAMEBUFFER, m_fbname); glReportError(); // The depth buffer if (zflags&HASZ) { glGenRenderbuffers(1, &m_zrbname); glReportError(); glBindRenderbuffer(GL_RENDERBUFFER, m_zrbname); glReportError(); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); glReportError(); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_zrbname); glReportError(); gpuMemoryUsed += width * height * 2; } else { m_zrbname = 0; } // Set "renderedTexture" as our colour attachement #0 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texname, 0); glReportError(); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_texname); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); #if 0 // Set the list of draw buffers. GLenum DrawBuffers[2] = {GL_COLOR_ATTACHMENT0}; glDrawBuffers(1, DrawBuffers); // "1" is the size of DrawBuffers #endif // Always check that our framebuffer is ok glReportError(); glReportFramebufferError(); }