Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pypocketfft
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Reinecke
pypocketfft
Commits
83408785
Commit
83408785
authored
Jun 25, 2019
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow cache disabling, tweak LRU counter
parent
eb9c915c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
pocketfft_hdronly.h
pocketfft_hdronly.h
+22
-8
No files found.
pocketfft_hdronly.h
View file @
83408785
...
...
@@ -41,7 +41,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#error This file requires at least C++11 support.
#endif
#include <array>
#ifndef POCKETFFT_CACHE_SIZE
#define POCKETFFT_CACHE_SIZE 16
#endif
#include <cmath>
#include <cstring>
#include <cstdlib>
...
...
@@ -49,7 +52,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
#include <vector>
#include <complex>
#if POCKETFFT_CACHE_SIZE!=0
#include <array>
#include <mutex>
#endif
#ifdef POCKETFFT_OPENMP
#include <omp.h>
#endif
...
...
@@ -2266,7 +2272,10 @@ template<typename T0> class pocketfft_r
template
<
typename
T
>
shared_ptr
<
T
>
get_plan
(
size_t
length
)
{
constexpr
size_t
nmax
=
10
;
#if POCKETFFT_CACHE_SIZE==0
return
make_shared
<
T
>
(
length
);
#else
constexpr
size_t
nmax
=
POCKETFFT_CACHE_SIZE
;
static
array
<
shared_ptr
<
T
>
,
nmax
>
cache
;
static
array
<
size_t
,
nmax
>
last_access
{{
0
}};
static
size_t
access_counter
=
0
;
...
...
@@ -2274,17 +2283,21 @@ template<typename T> shared_ptr<T> get_plan(size_t length)
auto
find_in_cache
=
[
&
]()
->
shared_ptr
<
T
>
{
for
(
size_t
i
=
0
;
i
<
nmax
;
++
i
)
if
(
cache
[
i
]
&&
(
cache
[
i
]
->
length
()
==
length
))
for
(
size_t
i
=
0
;
i
<
nmax
;
++
i
)
if
(
cache
[
i
]
&&
(
cache
[
i
]
->
length
()
==
length
))
{
// no need to update if this is already the most recent entry
if
(
last_access
[
i
]
!=
access_counter
)
{
last_access
[
i
]
=
access_counter
++
;
last_access
[
i
]
=
++
access_counter
;
// Guard against overflow
if
(
access_counter
==
0
)
last_access
.
fill
(
0
);
return
cache
[
i
];
}
return
cache
[
i
];
}
return
nullptr
;
return
nullptr
;
};
{
...
...
@@ -2304,9 +2317,10 @@ template<typename T> shared_ptr<T> get_plan(size_t length)
lru
=
i
;
cache
[
lru
]
=
plan
;
last_access
[
lru
]
=
access_counter
++
;
last_access
[
lru
]
=
++
access_counter
;
}
return
plan
;
#endif
}
class
arr_info
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment