Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Re: Prediction ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 20 Topic 2371 of 2529
Post > Topic >>

Re: Prediction of local code modifications

by Max Hailperin <max@[EMAIL PROTECTED] > Apr 2, 2008 at 07:42 AM

Tim Frink <plfriko@[EMAIL PROTECTED]
> writes:
>...
> I'm not sure if dynamic programming is an approach that I can apply to
> my problem [of deciding which blocks to move to faster memory]....

From your original posting, it is not clear to me which of the
following problems you want to solve (in each case, optimizing the
total speed of the program, which is dependent on the addresses of the
blocks):

(1) For each block, make a yes/no decision on whether to move it to
the faster memory.  The address of each block within its memory (the
slow memory or the fast memory) is equal to the sum of the size of the
preceding blocks that were assigned to the same memory.  That is, the
order of the blocks within each memory remains the same as in the
original layout and no padding bytes are introduced.

(2) Make the same decisions as problem (1), but if an N-byte block is
moved to the fast memory, up to N padding bytes can be left in its
place in the slow memory.  The actual number of padding bytes is an
additional output of the decision process.

(3) Solve some other even more general placement problem, where the
number of padding bytes is not limited to N, or padding bytes are also
allowed in the fast memory, or the blocks can be permuted into a
different order.

For the moment, I will assume you want to solve problem (1), both
because this seems closest to the way you initially stated the
problem, and because it is the simplest.

For this problem, dynamic programming is indeed a useful technique.
Consider working sequentially through the list of blocks, deciding for
each one whether to move it to fast memory or not.  The optimal
decision on whether to move block k does not depend on the specific
choices you made regarding each of blocks 1 through k-1.  Instead, it
just depends on the total size in bytes of the blocks in the range
from 1 through k-1 that were selected for fast memory.  This total
size is what determines all three relevant facts: (1) how many bytes
of the fast memory's capacity are still available for blocks k and
onward, (2) what the address of block k would be if left in the slow
memory, (3) what the address of block k would be if moved to the fast
memory.

This would lead to a dynamic programming solution using a
two-dimensional table, with one dimension indexed by block number and
the other dimension indexed by number of bytes.

The other piece of guidance I would offer is to look specifically at
the literature on dynamic programming solutions to the knapsack
problem, rather than just dynamic programming in general.  Your
problem (or at least what I am taking to be your problem -- number 1
in my list) is a generalization of the 0-1 knapsack problem.  Unlike
the standard problem, the items are in a sequence rather than a set
and the value of each item changes depending on how much of the
capacity of the knapsack is filled.  However, the standard dynamic
programming approach to the knapsack problem still works.
 




 20 Posts in Topic:
Prediction of local code modifications
Tim Frink <plfriko@[EM  2008-03-27 14:30:25 
Re: Prediction of local code modifications
glen herrmannsfeldt <g  2008-03-28 02:44:26 
Re: Prediction of local code modifications
"preston.briggs@[EMA  2008-03-28 14:26:42 
Re: Prediction of local code modifications
Max Hailperin <max@[EM  2008-03-28 19:40:17 
Re: Prediction of local code modifications
glen herrmannsfeldt <g  2008-03-29 11:33:00 
Re: Prediction of local code modifications
"preston.briggs@[EMA  2008-03-29 23:35:53 
Re: Prediction of local code modifications
Tim Frink <plfriko@[EM  2008-04-01 09:23:23 
Re: Prediction of local code modifications
"preston.briggs@[EMA  2008-04-01 23:01:46 
Re: Prediction of local code modifications
Max Hailperin <max@[EM  2008-04-02 07:42:57 
Re: Prediction of local code modifications
Tim Frink <plfriko@[EM  2008-04-03 21:22:40 
Re: Prediction of local code modifications
George Neuner <gneuner  2008-04-04 18:23:56 
Re: Prediction of local code modifications
Tim Frink <plfriko@[EM  2008-04-08 21:06:19 
Re: Prediction of local code modifications
gneuner <gneuner@[EMAI  2008-04-19 20:42:21 
Re: Prediction of local code modifications
Chris F Clark <cfc@[EM  2008-04-02 11:24:17 
Re: Prediction of local code modifications
glen herrmannsfeldt <g  2008-04-03 00:02:21 
Re: Prediction of local code modifications
Max Hailperin <max@[EM  2008-04-03 10:22:36 
Re: Prediction of local code modifications
Chris F Clark <cfc@[EM  2008-04-04 20:13:17 
Re: Prediction of local code modifications
Matthias Blume <find@[  2008-04-04 00:21:38 
Re: Prediction of local code modifications
Chris F Clark <cfc@[EM  2008-04-05 09:43:16 
Re: Prediction of local code modifications
Mayan Moudgill <mayan@  2008-04-05 21:35:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 4:35:50 CDT 2008.