Prefetcher.cc (9507:d2ab6d889fc7) | Prefetcher.cc (10466:73b7549d979e) |
---|---|
1/* 2 * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 31 unchanged lines hidden (view full) --- 40Prefetcher::Prefetcher(const Params *p) 41 : SimObject(p), m_num_streams(p->num_streams), 42 m_array(p->num_streams), m_train_misses(p->train_misses), 43 m_num_startup_pfs(p->num_startup_pfs), m_num_unit_filters(p->unit_filter), 44 m_num_nonunit_filters(p->nonunit_filter), 45 m_unit_filter(p->unit_filter, Address(0)), 46 m_negative_filter(p->unit_filter, Address(0)), 47 m_nonunit_filter(p->nonunit_filter, Address(0)), | 1/* 2 * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 31 unchanged lines hidden (view full) --- 40Prefetcher::Prefetcher(const Params *p) 41 : SimObject(p), m_num_streams(p->num_streams), 42 m_array(p->num_streams), m_train_misses(p->train_misses), 43 m_num_startup_pfs(p->num_startup_pfs), m_num_unit_filters(p->unit_filter), 44 m_num_nonunit_filters(p->nonunit_filter), 45 m_unit_filter(p->unit_filter, Address(0)), 46 m_negative_filter(p->unit_filter, Address(0)), 47 m_nonunit_filter(p->nonunit_filter, Address(0)), |
48 m_prefetch_cross_pages(p->cross_page) | 48 m_prefetch_cross_pages(p->cross_page), 49 m_page_shift(p->sys->getPageShift()) |
49{ 50 assert(m_num_streams > 0); 51 assert(m_num_startup_pfs <= MAX_PF_INFLIGHT); 52 53 // create +1 stride filter 54 m_unit_filter_index = 0; 55 m_unit_filter_hit = new uint32_t[m_num_unit_filters]; 56 for (uint32_t i =0; i < m_num_unit_filters; i++) { --- 169 unchanged lines hidden (view full) --- 226 227 // if (for some reason), this stream is unallocated, return. 228 if (stream == NULL) { 229 DPRINTF(RubyPrefetcher, "Unallocated stream, returning\n"); 230 return; 231 } 232 233 // extend this prefetching stream by 1 (or more) | 50{ 51 assert(m_num_streams > 0); 52 assert(m_num_startup_pfs <= MAX_PF_INFLIGHT); 53 54 // create +1 stride filter 55 m_unit_filter_index = 0; 56 m_unit_filter_hit = new uint32_t[m_num_unit_filters]; 57 for (uint32_t i =0; i < m_num_unit_filters; i++) { --- 169 unchanged lines hidden (view full) --- 227 228 // if (for some reason), this stream is unallocated, return. 229 if (stream == NULL) { 230 DPRINTF(RubyPrefetcher, "Unallocated stream, returning\n"); 231 return; 232 } 233 234 // extend this prefetching stream by 1 (or more) |
234 Address page_addr = page_address(stream->m_address); | 235 Address page_addr = pageAddress(stream->m_address); |
235 Address line_addr = next_stride_address(stream->m_address, 236 stream->m_stride); 237 238 // possibly stop prefetching at page boundaries | 236 Address line_addr = next_stride_address(stream->m_address, 237 stream->m_stride); 238 239 // possibly stop prefetching at page boundaries |
239 if (page_addr != page_address(line_addr)) { | 240 if (page_addr != pageAddress(line_addr)) { |
240 numPagesCrossed++; 241 if (!m_prefetch_cross_pages) { 242 // Deallocate the stream since we are not prefetching 243 // across page boundries 244 stream->m_is_valid = false; 245 return; 246 } 247 } --- 42 unchanged lines hidden (view full) --- 290 PrefetchEntry *mystream = &(m_array[index]); 291 mystream->m_address = line_address(address); 292 mystream->m_stride = stride; 293 mystream->m_use_time = m_controller->curCycle(); 294 mystream->m_is_valid = true; 295 mystream->m_type = type; 296 297 // create a number of initial prefetches for this stream | 241 numPagesCrossed++; 242 if (!m_prefetch_cross_pages) { 243 // Deallocate the stream since we are not prefetching 244 // across page boundries 245 stream->m_is_valid = false; 246 return; 247 } 248 } --- 42 unchanged lines hidden (view full) --- 291 PrefetchEntry *mystream = &(m_array[index]); 292 mystream->m_address = line_address(address); 293 mystream->m_stride = stride; 294 mystream->m_use_time = m_controller->curCycle(); 295 mystream->m_is_valid = true; 296 mystream->m_type = type; 297 298 // create a number of initial prefetches for this stream |
298 Address page_addr = page_address(mystream->m_address); | 299 Address page_addr = pageAddress(mystream->m_address); |
299 Address line_addr = line_address(mystream->m_address); 300 Address prev_addr = line_addr; 301 302 // insert a number of prefetches into the prefetch table 303 for (int k = 0; k < m_num_startup_pfs; k++) { 304 line_addr = next_stride_address(line_addr, stride); 305 // possibly stop prefetching at page boundaries | 300 Address line_addr = line_address(mystream->m_address); 301 Address prev_addr = line_addr; 302 303 // insert a number of prefetches into the prefetch table 304 for (int k = 0; k < m_num_startup_pfs; k++) { 305 line_addr = next_stride_address(line_addr, stride); 306 // possibly stop prefetching at page boundaries |
306 if (page_addr != page_address(line_addr)) { | 307 if (page_addr != pageAddress(line_addr)) { |
307 numPagesCrossed++; 308 if (!m_prefetch_cross_pages) { 309 // deallocate this stream prefetcher 310 mystream->m_is_valid = false; 311 return; 312 } 313 } 314 --- 62 unchanged lines hidden (view full) --- 377bool 378Prefetcher::accessNonunitFilter(const Address& address, int *stride, 379 bool &alloc) 380{ 381 //reset the alloc flag 382 alloc = false; 383 384 /// look for non-unit strides based on a (user-defined) page size | 308 numPagesCrossed++; 309 if (!m_prefetch_cross_pages) { 310 // deallocate this stream prefetcher 311 mystream->m_is_valid = false; 312 return; 313 } 314 } 315 --- 62 unchanged lines hidden (view full) --- 378bool 379Prefetcher::accessNonunitFilter(const Address& address, int *stride, 380 bool &alloc) 381{ 382 //reset the alloc flag 383 alloc = false; 384 385 /// look for non-unit strides based on a (user-defined) page size |
385 Address page_addr = page_address(address); | 386 Address page_addr = pageAddress(address); |
386 Address line_addr = line_address(address); 387 388 for (uint32_t i = 0; i < m_num_nonunit_filters; i++) { | 387 Address line_addr = line_address(address); 388 389 for (uint32_t i = 0; i < m_num_nonunit_filters; i++) { |
389 if (page_address(m_nonunit_filter[i]) == page_addr) { | 390 if (pageAddress(m_nonunit_filter[i]) == page_addr) { |
390 // hit in the non-unit filter 391 // compute the actual stride (for this reference) 392 int delta = line_addr.getAddress() - m_nonunit_filter[i].getAddress(); 393 394 if (delta != 0) { 395 // no zero stride prefetches 396 // check that the stride matches (for the last N times) 397 if (delta == m_nonunit_stride[i]) { --- 64 unchanged lines hidden (view full) --- 462 out << "streams:\n"; 463 for (int i = 0; i < m_num_streams; i++) { 464 out << m_array[i].m_address << " " 465 << m_array[i].m_stride << " " 466 << m_array[i].m_is_valid << " " 467 << m_array[i].m_use_time << std::endl; 468 } 469} | 391 // hit in the non-unit filter 392 // compute the actual stride (for this reference) 393 int delta = line_addr.getAddress() - m_nonunit_filter[i].getAddress(); 394 395 if (delta != 0) { 396 // no zero stride prefetches 397 // check that the stride matches (for the last N times) 398 if (delta == m_nonunit_stride[i]) { --- 64 unchanged lines hidden (view full) --- 463 out << "streams:\n"; 464 for (int i = 0; i < m_num_streams; i++) { 465 out << m_array[i].m_address << " " 466 << m_array[i].m_stride << " " 467 << m_array[i].m_is_valid << " " 468 << m_array[i].m_use_time << std::endl; 469 } 470} |
471 472Address 473Prefetcher::pageAddress(const Address& addr) const 474{ 475 Address temp = addr; 476 temp.maskLowOrderBits(m_page_shift); 477 return temp; 478} |
|