<p>I am not sure I understood the question.  But it seems to me that under the assumption that $PSPACE$ contains problems requiring exponential time, such problems would fulfill your requirements, since if $M$ is $O(\log N)$ you would need an exponential number of I/O operations (since you can't "stay" in the same memory block of size $O( \log N)$ more than a polynomial number of steps without going into a cycle) and if $M=N$ you would only need a linear number of I/O operations. Also, concerning your observation that such a problem cannot belong to $P$, it is correct if the speedup must hold for values of $M$ that are $\Omega(N)$ (since it would mean we have an exponential number of operations). But if the speedup only applies to smaller values of $M$, intuitively I believe this is not true, because I feel it should be possible to design a problem that is in fact the concatenation of smaller problems of size $O(\log N)$ each requiring exponential time in its own size, and an exponential number of I/O operations (that is, $poly (N)$, since $poly(N)$ is exponential in $O(\log N)$). In practice I believe $PSPACE$-complete problems such as $TQBF$ fulfill your condition.</p>

CC BY-SA 3.0
2013-02-09T15:36:08.013Z
I'm afraid I don't follow some of your arguments.  If $M= \Omega(N)$, any problem in external memory is trivial.  As I mentioned, $M = O(\log N)$ is somewhat silly as that means memory has only a constant number of words (possible but not how external memory is generally examined).  I see what you're saying that there was exponential gain, but that doesn't say anything about intermediate values.  For example, optimal Partition in external memory is the min of two terms (essentially if everything fits in memory we do something entirely different than if it doesn't).  Can you rule that out?
SamM
CC BY-SA 3.0
2013-02-09T16:18:52.637Z
I don't understand why any problem in external memory is trivial if $M = \Omega(N)$. If $M=N/2$ and the algorithm takes,  exponential time, you might be forced to swap back and forth between (so to speak) the two halves of the memory an exponential number of times.
user8477
CC BY-SA 3.0
2013-02-09T16:44:19.067Z
Ah, of course you're right about the constant factor being important.  That makes a lot of sense; this is certainly a good starting point.
SamM
CC BY-SA 3.0
2013-02-09T16:54:22.897Z
I don't have any argument for intermediate values. At a very superficial level, I guess that some backtracking algorithms would have an exponential dependence on the memory size because I/O operations would be required at nodes of lower depth in the search tree. This dependence would apply to intermediate values. This says nothing about the inherent complexity of the problem, of course. Also, if you have $M=\omega(\log N)$, the pigeonhole (cycling) argument given above would still yield a gain of $T(N)/2^M$ where $T(N)$ is the time complexity of the problem.
user8477
CC BY-SA 3.0
2013-02-08T22:18:38.023Z
2013-02-08T22:18:38.023Z
user8477
<p>this question appears to veer into <em>terra incognita</em> ie unexplored territory. after some thinking &amp; review here are some thoughts/ideas on this apparently very difficult/subtle question which hopefully will be intelligent but are not meant to be definitive.</p>

<p>Demain who you cite writes, "the principle idea [of cache oblivious algorithms] is simple: design external-memory algorithms without knowing $B$ and $M$. But this simple idea has several surprisingly powerful consequences."</p>

<p>it also appears to have surprisingly subtle implications. it appears hard to analyze this model for extremal behavior and it appears nobody has done this so far. there are some surveys and they seem to survey the entire field so far. this is not surprising given the field is only ~1 decade old.</p>

<ul>
<li><p>the model does not appear to have been translated to Turing machines yet where more strict/formal/theoretical/general/standard analysis may be possible. the whole concept of Big-Oh notation and its implications and intuitions such as irrelevance of constants is not necessarily automatically carrying in this area of cache oblivious algorithms. for example the model already seems to be working with constants $B,M$ which measure exact memory sizes. it appears the field does not have a set of basic axioms of its dynamics so far.</p></li>
<li><p>TMs were invented in 1936 by Turing and the Hartmanis-Stearns <a href="http://en.wikipedia.org/wiki/Time_hierarchy_theorem" rel="nofollow noreferrer">time/space hierarchy theorems</a> (which you are somewhat alluding to in this question) were discovered in 1965. thats a remarkable ~3 <em>decades</em> yet the time/space hierarchy theorems are now considered somewhat elementary and taught in undergraduate classes. there does not seem to be corresponding hierarchy theorems established in this model yet, and how to do that is not a trivial problem. this model actually seems to have more "moving parts" than the standard Turing machine (which already has a rather fiendishly complex dynamics), ie is like an augmented Turing machine.</p></li>
<li><p>another idea is to convert this external memory model to TMs somehow, which again does not appear to show up in the literature/surveys on cache oblivious algorithms, and maybe see how the Hartmanis-Stearns hierarchy theorems could translate. it appears to relate to a two tape TM where one tape is size 'M' and the other tape is infinite, and blocks are transferred to 'M' in sizes of 'B'. but also, a difficulty here is it is more of a RAM model than the Turing model which uses sequential access to the tape. on the other hand this could run into subtleties associated with <a href="https://cstheory.stackexchange.com/questions/10990/why-do-we-use-single-tape-turing-machines-for-time-complexity">conversions between single and multitape TMs</a>.</p></li>
<li><p>suggest attacking this problem empirically with simulations which is where the literature tends to focus on eg as in this great survey by Kumar on <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.150.5426" rel="nofollow noreferrer">Cache oblivious algorithms</a> (2003). there are many programs and papers online for cache simulations and one could possibly answer your question without a large amount of code, using some simplifications. one basic idea is to create probabilistic algorithms which access "nearby" areas of memory based on probabilities. "nearby" here is not necessarily contiguous memory, but instead an algorithm that selects random memory pages (blocks) based on keeping track of its own most recently accessed pages. suggest using <a href="http://en.wikipedia.org/wiki/Power_law" rel="nofollow noreferrer">power laws</a> to determine the probability of selecting "near" pages in the "most recently accessed" list. this appears to be the key aspect that cache-based performance improvements are related to.</p></li>
<li><p>heres a rough argument based on 'M' which is basically a measure of "core memory" versus disk memory. for an algorithm, one would expect as core memory increases, one only comes close [asymptotically] to a linear improvement in algorithmic speed, and adding "core memory" to get any super-linear increase in algorithm speed seems intuitively almost like exceeding the speed limit and "getting something for nothing". however, dont grasp the model well enough to prove this [but apparently no one else has either, including the authorities/founders/experts].</p></li>
<li><p>this cache-oblivious algorithm literature has focused on P algorithms and did not see any case at all of an analysis of a non-P algorithm so far and perhaps none exists. this could possibly be because the analysis is too difficult! in which case, questions about extremal behavior may go unanswered in this field in the long term.</p></li>
<li><p>it does not even seem intuitively clear, or possibly at all studied yet, about how "small" complexity algorithms such as in L, or "big" algorithms such as non-P (eg Expspace etc) behave in this model. the model is measuring memory locality, which seems to be fundamentally different, but intertwined with, time and space hierarchies.</p></li>
<li><p>there is a somewhat obscure measurement of Turing machine complexity called "reversal complexity" with some study, results, and papers that might be related. basically the TM can cover a certain amount of time and space, but reversals are a somewhat independent measurement of the tape head during the computation. it seems that "high reversals" might be related to "high memory locality" because in both cases the tape head is tending to stay in a "smaller" region versus moving into larger regions.</p></li>
<li><p>this question and model reminds me of <a href="http://en.wikipedia.org/wiki/Amdahl&#39;s_law" rel="nofollow noreferrer">Amdahls law</a> and suspect some kind of yet-undiscovered similar law related to diminishing returns or balances/tradeoffs might hold or be applicable in this area. rough reasoning: cache oblivious algorithm theory is looking at a balance/tradeoff between a finite "local" memory and a cost-based external "infinite" disk. this is basically two resources that behave "in parallel" and there is likely some kind of optimal tradeoff between them.</p></li>
</ul>

CC BY-SA 3.0
2013-02-10T20:13:51.203Z
In your first point, what would "more theoretical analysis" even mean? A TM doesn't have a $k$-level memory hierarchy. The ideal-cache model is easy and natural to work with, and has been experimentally proven to be a useful model with respect to memory behavior on real systems.
Juho
CC BY-SA 3.0
2013-02-10T20:35:57.090Z
the TM model is the basic model of TCS and "bridge thms" between its complexity hierarchy (time/space, basic complexity classes such as P/NP etc) with cache oblivious algorithms apparently remain to be mapped out. the external memory models & related cache oblivious models are basically attempting to model real-world performance characteristics & the literature is not so far interested in greater theoretical abstractions such as asked by the question.
vzn
CC BY-SA 3.0
2013-02-10T02:03:04.843Z
2013-02-10T02:09:00.937Z
2017-04-13T12:32:28.117Z
vzn
<p><strong>Background</strong></p>

<p>The external memory, or DAM model, defines the cost of an algorithm by the number of I/Os it performs (essentially, the number of cache misses).  These running times are generally given in terms of $M$, the size of memory, and $B$, the number of words that can be transferred to memory at one time.  Sometimes $L$ and $Z$ are used for $B$ and $M$ respectively.  </p>

<p>For example, sorting requires a cost of $\Theta(N/B\log_{M/B} N/B)$ and naive matrix multiplication requires $\Theta(n^3/B\sqrt{M})$.  </p>

<p>This model is used to analyze "cache-oblivious algorithms", which do not have knowledge of $B$ or $M$.  Generally the goal is for the cache-oblivious algorithm to perform optimally in the external memory model; this is not always possible, as in the Permutation problem for example (shown in <a href="http://dl.acm.org/citation.cfm?id=780589">Brodal, Faderberg 2003</a>).  See <a href="https://cs.uwaterloo.ca/~imunro/cs840/DemaineCache.pdf">this writeup by Erik Demaine</a> for a further explanation of cache-oblivious algorithms, including discussions of sorting and matrix multiplication.</p>

<p>We can see that changing $M$ causes a logarithmic speedup for sorting and a polynomial speedup for matrix multiplication.  (This result is originally from <a href="http://dl.acm.org/citation.cfm?id=802486">Hong, Kung 1981</a> and actually predates both cache obliviousness and the formalization of the external memory model). </p>

<p><strong>My question is this:</strong></p>

<p>Is there any case where the speedup is exponential in $M$? The running time would be something like $f(N,B)/2^{O(M)}$. I am particularly interested in a cache-oblivious algorithm or data structure that fits this description but would be happy with a cache-aware algorithm/data structure or even a best-known lower bound.</p>

<p>It is generally assumed in most models that the word size $w = \Omega(\log N)$ if $N$ is the input size and clearly $M &gt; w$.  Then a speedup of $2^M$ gives a polynomial speedup in $N$.  This makes me believe that if the problem I'm looking for exists, it is not polynomial.  (Otherwise we can change the cache size by a constant to obtain a constant number of I/Os, which seems unlikely).</p>

CC BY-SA 3.0
2013-02-07T06:07:19.990Z
can guess, but $N=$? found a case given as speedup $B^{\rm{polylog}(B)}$, sufficient?
vzn
CC BY-SA 3.0
2013-02-07T16:24:03.300Z
It has to be in terms of $M$ for my purposes, unfortunately.  I'd be interested in the reference though.
SamM
CC BY-SA 3.0
2013-02-07T20:00:07.707Z
wikipedia on [cache oblivious algorithms](http://en.wikipedia.org/wiki/Cache-oblivious_algorithm). fyi there is some subtlety in this fields notation. p7 footnote of Demaine says in this area, $N$ is problem size & sometimes $n = N/B$ where $n$ is number of blocks, "but the lower case notation seems to have fallen out of favor". you use $n$ above and alternatively $N$ apparently both as input size. think you should at least standardize in your question.
vzn
CC BY-SA 3.0
2013-02-07T20:06:43.923Z
I edited it for consistency.  $N$ is the size of the input, and $n$ is only used for matrix multiplication because the running time for that problem is generally defined in terms of an $n\times n$ matrix (i.e. $N = n^2$)
SamM
CC BY-SA 3.0
2013-02-07T22:28:25.427Z
do not see cases of this after scanning the literature. maybe there is no such ref? maybe there is some case to be made that any such algorithm might be complex and therefore hard to theoretically analyze to obtain such a speedup...? or maybe it would have to be contrived...? or, maybe it is not possible? could there be an idea that random access to memory is the worst case possible? seems like the increase for speed is linear in $M$ for that case...? or, maybe some fractal pattern of access to memory is worst case? this line of study is only a little more than a decade old....
vzn
CC BY-SA 3.0
2013-02-07T22:38:45.063Z
you mean $\Theta(n^3/(B\sqrt{M}))$ for matrix multiplication right?
vzn
CC BY-SA 3.0
2013-02-10T06:45:17.223Z
ok here is the case that is superpolylogarithmic but exponentially-subpolynomial in $B$, the case of [shuttle trees](http://publications.csail.mit.edu/abstracts/abstracts07/jfineman/jfineman.html) in the paper "streaming cache oblivious B-trees" by Bender et al
vzn
<ds.algorithms><ds.data-structures><cache-oblivious>
Exponential Speedup in External Memory
SamM
# Exponential Speedup in External Memory

(Asked by: username_0 on 2013-02-04)

**Background**

The external memory, or DAM model, defines the cost of an algorithm by the number of I/Os it performs (essentially, the number of cache misses). These running times are generally given in terms of $M$, the size of memory, and $B$, the number of words that can be transferred to memory at one time. Sometimes $L$ and $Z$ are used for $B$ and $M$ respectively.

For example, sorting requires a cost of $\Theta(N/B\log\_{M/B} N/B)$ and naive matrix multiplication requires $\Theta(n^3/B\sqrt{M})$.

This model is used to analyze "cache-oblivious algorithms", which do not have knowledge of $B$ or $M$. Generally the goal is for the cache-oblivious algorithm to perform optimally in the external memory model; this is not always possible, as in the Permutation problem for example (shown in [Brodal, Faderberg 2003](http://dl.acm.org/citation.cfm?id=780589)). See [this writeup by Erik Demaine](https://cs.uwaterloo.ca/~imunro/cs840/DemaineCache.pdf) for a further explanation of cache-oblivious algorithms, including discussions of sorting and matrix multiplication.

We can see that changing $M$ causes a logarithmic speedup for sorting and a polynomial speedup for matrix multiplication. (This result is originally from [Hong, Kung 1981](http://dl.acm.org/citation.cfm?id=802486) and actually predates both cache obliviousness and the formalization of the external memory model).

**My question is this:**

Is there any case where the speedup is exponential in $M$? The running time would be something like $f(N,B)/2^{O(M)}$. I am particularly interested in a cache-oblivious algorithm or data structure that fits this description but would be happy with a cache-aware algorithm/data structure or even a best-known lower bound.

It is generally assumed in most models that the word size $w = \Omega(\log N)$ if $N$ is the input size and clearly $M > w$. Then a speedup of $2^M$ gives a polynomial speedup in $N$. This makes me believe that if the problem I'm looking for exists, it is not polynomial. (Otherwise we can change the cache size by a constant to obtain a constant number of I/Os, which seems unlikely).

**Tags:** ds.algorithms, ds.data-structures, cache-oblivious

> **Comments:**
> **username_1**: can guess, but $N=$? found a case given as speedup $B^{\rm{polylog}(B)}$, sufficient?  
> **username_0**: It has to be in terms of $M$ for my purposes, unfortunately.  I'd be interested in the reference though.  
> **username_1**: wikipedia on [cache oblivious algorithms](http://en.wikipedia.org/wiki/Cache-oblivious_algorithm). fyi there is some subtlety in this fields notation. p7 footnote of Demaine says in this area, $N$ is problem size & sometimes $n = N/B$ where $n$ is number of blocks, "but the lower case notation seems to have fallen out of favor". you use $n$ above and alternatively $N$ apparently both as input size. think you should at least standardize in your question.  
> **username_0**: I edited it for consistency.  $N$ is the size of the input, and $n$ is only used for matrix multiplication because the running time for that problem is generally defined in terms of an $n\times n$ matrix (i.e. $N = n^2$)  
> **username_1**: do not see cases of this after scanning the literature. maybe there is no such ref? maybe there is some case to be made that any such algorithm might be complex and therefore hard to theoretically analyze to obtain such a speedup...? or maybe it would have to be contrived...? or, maybe it is not possible? could there be an idea that random access to memory is the worst case possible? seems like the increase for speed is linear in $M$ for that case...? or, maybe some fractal pattern of access to memory is worst case? this line of study is only a little more than a decade old....  
> **username_1**: you mean $\Theta(n^3/(B\sqrt{M}))$ for matrix multiplication right?  
> **username_1**: ok here is the case that is superpolylogarithmic but exponentially-subpolynomial in $B$, the case of [shuttle trees](http://publications.csail.mit.edu/abstracts/abstracts07/jfineman/jfineman.html) in the paper "streaming cache oblivious B-trees" by Bender et al  

---

## 2 answers

### Answer by username_2 on 2013-02-08. Score: 3

I am not sure I understood the question. But it seems to me that under the assumption that $PSPACE$ contains problems requiring exponential time, such problems would fulfill your requirements, since if $M$ is $O(\log N)$ you would need an exponential number of I/O operations (since you can't "stay" in the same memory block of size $O( \log N)$ more than a polynomial number of steps without going into a cycle) and if $M=N$ you would only need a linear number of I/O operations. Also, concerning your observation that such a problem cannot belong to $P$, it is correct if the speedup must hold for values of $M$ that are $\Omega(N)$ (since it would mean we have an exponential number of operations). But if the speedup only applies to smaller values of $M$, intuitively I believe this is not true, because I feel it should be possible to design a problem that is in fact the concatenation of smaller problems of size $O(\log N)$ each requiring exponential time in its own size, and an exponential number of I/O operations (that is, $poly (N)$, since $poly(N)$ is exponential in $O(\log N)$). In practice I believe $PSPACE$-complete problems such as $TQBF$ fulfill your condition.

> **Comments:**
> **username_0**: I'm afraid I don't follow some of your arguments.  If $M= \Omega(N)$, any problem in external memory is trivial.  As I mentioned, $M = O(\log N)$ is somewhat silly as that means memory has only a constant number of words (possible but not how external memory is generally examined).  I see what you're saying that there was exponential gain, but that doesn't say anything about intermediate values.  For example, optimal Partition in external memory is the min of two terms (essentially if everything fits in memory we do something entirely different than if it doesn't).  Can you rule that out?  
> **username_2**: I don't understand why any problem in external memory is trivial if $M = \Omega(N)$. If $M=N/2$ and the algorithm takes,  exponential time, you might be forced to swap back and forth between (so to speak) the two halves of the memory an exponential number of times.  
> **username_0**: Ah, of course you're right about the constant factor being important.  That makes a lot of sense; this is certainly a good starting point.  
> **username_2**: I don't have any argument for intermediate values. At a very superficial level, I guess that some backtracking algorithms would have an exponential dependence on the memory size because I/O operations would be required at nodes of lower depth in the search tree. This dependence would apply to intermediate values. This says nothing about the inherent complexity of the problem, of course. Also, if you have $M=\omega(\log N)$, the pigeonhole (cycling) argument given above would still yield a gain of $T(N)/2^M$ where $T(N)$ is the time complexity of the problem.  

---

### Answer by username_1 on 2013-02-10. Score: -4

this question appears to veer into *terra incognita* ie unexplored territory. after some thinking & review here are some thoughts/ideas on this apparently very difficult/subtle question which hopefully will be intelligent but are not meant to be definitive.

Demain who you cite writes, "the principle idea [of cache oblivious algorithms] is simple: design external-memory algorithms without knowing $B$ and $M$. But this simple idea has several surprisingly powerful consequences."

it also appears to have surprisingly subtle implications. it appears hard to analyze this model for extremal behavior and it appears nobody has done this so far. there are some surveys and they seem to survey the entire field so far. this is not surprising given the field is only ~1 decade old.

* the model does not appear to have been translated to Turing machines yet where more strict/formal/theoretical/general/standard analysis may be possible. the whole concept of Big-Oh notation and its implications and intuitions such as irrelevance of constants is not necessarily automatically carrying in this area of cache oblivious algorithms. for example the model already seems to be working with constants $B,M$ which measure exact memory sizes. it appears the field does not have a set of basic axioms of its dynamics so far.
* TMs were invented in 1936 by Turing and the Hartmanis-Stearns [time/space hierarchy theorems](http://en.wikipedia.org/wiki/Time_hierarchy_theorem) (which you are somewhat alluding to in this question) were discovered in 1965. thats a remarkable ~3 *decades* yet the time/space hierarchy theorems are now considered somewhat elementary and taught in undergraduate classes. there does not seem to be corresponding hierarchy theorems established in this model yet, and how to do that is not a trivial problem. this model actually seems to have more "moving parts" than the standard Turing machine (which already has a rather fiendishly complex dynamics), ie is like an augmented Turing machine.
* another idea is to convert this external memory model to TMs somehow, which again does not appear to show up in the literature/surveys on cache oblivious algorithms, and maybe see how the Hartmanis-Stearns hierarchy theorems could translate. it appears to relate to a two tape TM where one tape is size 'M' and the other tape is infinite, and blocks are transferred to 'M' in sizes of 'B'. but also, a difficulty here is it is more of a RAM model than the Turing model which uses sequential access to the tape. on the other hand this could run into subtleties associated with [conversions between single and multitape TMs](https://cstheory.stackexchange.com/questions/10990/why-do-we-use-single-tape-turing-machines-for-time-complexity).
* suggest attacking this problem empirically with simulations which is where the literature tends to focus on eg as in this great survey by Kumar on [Cache oblivious algorithms](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.150.5426) (2003). there are many programs and papers online for cache simulations and one could possibly answer your question without a large amount of code, using some simplifications. one basic idea is to create probabilistic algorithms which access "nearby" areas of memory based on probabilities. "nearby" here is not necessarily contiguous memory, but instead an algorithm that selects random memory pages (blocks) based on keeping track of its own most recently accessed pages. suggest using [power laws](http://en.wikipedia.org/wiki/Power_law) to determine the probability of selecting "near" pages in the "most recently accessed" list. this appears to be the key aspect that cache-based performance improvements are related to.
* heres a rough argument based on 'M' which is basically a measure of "core memory" versus disk memory. for an algorithm, one would expect as core memory increases, one only comes close [asymptotically] to a linear improvement in algorithmic speed, and adding "core memory" to get any super-linear increase in algorithm speed seems intuitively almost like exceeding the speed limit and "getting something for nothing". however, dont grasp the model well enough to prove this [but apparently no one else has either, including the authorities/founders/experts].
* this cache-oblivious algorithm literature has focused on P algorithms and did not see any case at all of an analysis of a non-P algorithm so far and perhaps none exists. this could possibly be because the analysis is too difficult! in which case, questions about extremal behavior may go unanswered in this field in the long term.
* it does not even seem intuitively clear, or possibly at all studied yet, about how "small" complexity algorithms such as in L, or "big" algorithms such as non-P (eg Expspace etc) behave in this model. the model is measuring memory locality, which seems to be fundamentally different, but intertwined with, time and space hierarchies.
* there is a somewhat obscure measurement of Turing machine complexity called "reversal complexity" with some study, results, and papers that might be related. basically the TM can cover a certain amount of time and space, but reversals are a somewhat independent measurement of the tape head during the computation. it seems that "high reversals" might be related to "high memory locality" because in both cases the tape head is tending to stay in a "smaller" region versus moving into larger regions.
* this question and model reminds me of [Amdahls law](http://en.wikipedia.org/wiki/Amdahl's_law) and suspect some kind of yet-undiscovered similar law related to diminishing returns or balances/tradeoffs might hold or be applicable in this area. rough reasoning: cache oblivious algorithm theory is looking at a balance/tradeoff between a finite "local" memory and a cost-based external "infinite" disk. this is basically two resources that behave "in parallel" and there is likely some kind of optimal tradeoff between them.

> **Comments:**
> **username_3**: In your first point, what would "more theoretical analysis" even mean? A TM doesn't have a $k$-level memory hierarchy. The ideal-cache model is easy and natural to work with, and has been experimentally proven to be a useful model with respect to memory behavior on real systems.  
> **username_1**: the TM model is the basic model of TCS and "bridge thms" between its complexity hierarchy (time/space, basic complexity classes such as P/NP etc) with cache oblivious algorithms apparently remain to be mapped out. the external memory models & related cache oblivious models are basically attempting to model real-world performance characteristics & the literature is not so far interested in greater theoretical abstractions such as asked by the question.  

---

