# What does the cacheable parameter do in allocate function?

**URL:** <https://discuss.pynq.io/t/what-does-the-cacheable-parameter-do-in-allocate-function/2922>\
**Category:** Support\
**Created:** [August 12, 2021, 10:38am UTC](https://discuss.pynq.io/t/what-does-the-cacheable-parameter-do-in-allocate-function/2922 "2021-08-12T10:38:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abitofmaya](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@abitofmaya](https://discuss.pynq.io/u/abitofmaya)\
**Post date:** [August 12, 2021, 10:38am UTC](https://discuss.pynq.io/t/what-does-the-cacheable-parameter-do-in-allocate-function/2922/1 "2021-08-12T10:38:36Z")

</div>

I was working on a project that read message from a text file, encrypted it, wrote it to a file and then decrypted it back. I used the allocate function with the cacheable parameter set to True. That design worked partially, sometimes worked and sometimes didn’t. I then removed the cacheable parameter and the design worked.

Currently I am working with the VDMA IP. Now when I set the cacheable parameter to False, I get the following message on the serial terminal.

```auto
Alignment trap: not handling instruction f8513b03 at [<af922c0a>]
8<--- cut here ---
Unhandled fault: alignment exception (0x011) at 0xaad11003
pgd = d12b415c
[aad11003] *pgd=14f66831, *pte=16900703, *ppte=16900e33

```

This design only works when the cacheable parameter is True.

I want to know what is going on here. Why is it that sometimes it is required and sometimes its not?

Where does it allocate the buffer when cacheable is set to True and also when it is False?  
I have read the buffer is allocated on the L2 cache when True and on the DDR when False. I’m not sure.

I also read about the flush and invalidate functions, from [here.](https://discuss.pynq.io/t/fpga-data-movement-using-numpy/734). But I have not seen any examples that made use of these functions when cacheable is True, [Resizer example](https://github.com/Xilinx/PYNQ-HelloWorld/blob/master/pynq_helloworld/notebooks/edge/resizer_pl.ipynb). Is it handled automatically?

Also in [pynq.buffer.allocate(shape, dtype=‘u4’, target=None, \*\*kwargs)](https://pynq.readthedocs.io/en/v2.6.1/pynq_package/pynq.buffer.html#pynq.buffer.allocate), the description for the target parameter reads,

```auto
The target determines where the buffer gets allocated

If None then the currently active device is used
If a Device is specified then the main memory

```

What is the _currently active device_ and _Device_? Is _Device_ an object of the Device class?

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [October 1, 2021, 9:30am UTC](https://discuss.pynq.io/t/what-does-the-cacheable-parameter-do-in-allocate-function/2922/2 "2021-10-01T09:30:48Z")

</div>

Hi @abitofmaya,

There’s a discussion about cacheable here

> [@FPGA Data Movement Using NumPy](https://discuss.pynq.io/t/fpga-data-movement-using-numpy/734):
>
> [top\_logo] Without a doubt, [NumPy](https://numpy.org/) represents today the de facto standard Python package for array-processing. It provides a high-performance array object, and a wide variety of powerful tools to work with these arrays. Indeed, it is used pretty much everywhere! From scientific computing, to machine learning, to computer vision, and is integrated in many Python libraries. And the list goes on! PYNQ lives and breathes Python, we believe in the potential of this powerful productivity language and…

Mario
