Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2465 Discussions

Documentation/examples for concurrent_lru_cache?

e4lam
Beginner
1,101 Views
Hi, can someone point me to some examples and/or documentation for concurrent_lru_cache? I just see some vague mention of it being a new preview feature but it's a bit hard to understand how to use it just from the header file. Thanks!
0 Kudos
1 Solution
Vladimir_P_1234567890
1,101 Views
I've updated reference.pdf on the site.
--Vladimir

View solution in original post

0 Kudos
8 Replies
SergeyKostrov
Valued Contributor II
1,101 Views
Quoting e4lam
Hi, can someone point me to some examples and/or documentation for concurrent_lru_cache? I just see some vague mention of it being a new preview feature but it's a bit hard to understand how to use it just from the header file. Thanks!


What TBB version are you using?I just searched TBB v4.0 sources installed on my computer with
'concurrent_lru_cache' expression and I haven't found anything.

Best regards,
Sergey

0 Kudos
Vladimir_P_1234567890
1,101 Views
It should be in reference.pdf of TBB 4.0 update 2, in CPF section. We'll check it in OSS site and update ifnecessary.
Any feedback on this CPF is appreciated
Thanks!
Vladimir
0 Kudos
e4lam
Beginner
1,101 Views
@Sergey: As mentioned, it can be found in the sources for TBB 4 update 2. The corresponding commercially aligned OSS version is tbb40_278oss
0 Kudos
Vladimir_P_1234567890
1,101 Views
You're right, docs are up-to date and lru cache info is missed there.
it should be available in the reference in next update in a few weeks.
Meanwhile we are working to putting something lru cache related to the web.
stay tuned:)
--Vladimir
0 Kudos
Vladimir_P_1234567890
1,102 Views
I've updated reference.pdf on the site.
--Vladimir
0 Kudos
e4lam
Beginner
1,101 Views
Thanks for the update, Vladimir!

I've got some questions for you after reviewing the documentation.

- Has there been any changes to concurrent_lru_cache in the new TBB 4 Update 3? Can I simply try it out in TBB 4 Update 2?

- Will operator[]() block when adding a new cache item while all pre-existing items are already in use?

- How do you recommend using it efficiently for large value_type's given that value_functor_type returns the cache item by value? I'm not using C++11 yet so move operators are out of the question.

Thanks!
0 Kudos
Anton_P_Intel
Employee
1,101 Views
e4lam,
see bellow:

- Has there been any changes to concurrent_lru_cache in the new TBB 4 Update 3? Can I simply try it out in TBB 4 Update 2?
-- Yes, there were some minor changes to fix warnings on some compilers. However from end-user perspective there should no big difference in sense of container functionality.

- Will operator[]() block when adding a new cache item while all pre-existing items are already in use
-- the short answer is : no, it will not.
the long one is next: concurrent_lru_cache does not limit number of objects that are in use, instead it throws away extra _unused_ objects. (technically speaking some blocking is inevitable as internally locks are used to keep internal data structutres corects.)

- How do you recommend using it efficiently for large value_type's given that value_functor_type returns the cache item by value? I'm not using C++11 yet so move operators are out of the question.
-- the state of art is to use some kind of smart proxy objects like C++11 shared_ptr


Hope it helps :)
0 Kudos
Reply