HWCache

Allows to prefetch data into level 1 cache.

Summary
HWCacheAllows to prefetch data into level 1 cache.
CopyrightThis program is free software.
Files
C-kern/api/memory/hwcache.hHeader file HWCache.
C-kern/memory/hwcache.cImplementation file HWCache impl.
Types
struct hwcache_tExport hwcache_t into global namespace.
Functions
test
unittest_memory_hwcacheTest hwcache_t functionality.
hwcache_tImplicit type allows to access a hardware object.
query
sizedataprefetch_hwcacheSize of aligned memory block transfered to and from data cache.
update
prefetchdata_hwcachePrefetches data into all levels of hw cache.
inline implementation
Macros
prefetchdata_hwcacheImplements hwcache_t.prefetchdata_hwcache.
sizedataprefetch_hwcacheImplements hwcache_t.sizedataprefetch_hwcache.

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2012 Jörg Seebohn

Files

C-kern/api/memory/hwcache.h

Header file HWCache.

C-kern/memory/hwcache.c

Implementation file HWCache impl.

Types

struct hwcache_t

typedef struct hwcache_t hwcache_t

Export hwcache_t into global namespace.

Functions

Summary

test

unittest_memory_hwcache

int unittest_memory_hwcache(void)

Test hwcache_t functionality.

hwcache_t

struct hwcache_t

Implicit type allows to access a hardware object.

Summary
query
sizedataprefetch_hwcacheSize of aligned memory block transfered to and from data cache.
update
prefetchdata_hwcachePrefetches data into all levels of hw cache.

query

sizedataprefetch_hwcache

uint32_t sizedataprefetch_hwcache(void)

Size of aligned memory block transfered to and from data cache.  The stored blocks are also called cache lines internally.  A cache line stores more then raw data bytes.  It stores also the memory address and additional flags which describe the state of the cached data.

This value also gives the memory address alignment of such a cache line.

Dummy Implementation

The returned value is reasonable but does not adapt to the current hardware.  TODO: Implement it in a hardware specific way.

update

prefetchdata_hwcache

void prefetchdata_hwcache(void *addr)

Prefetches data into all levels of hw cache.  The transfered data block is of size sizedataprefetch_hwcache and has the same alignment.  The transfered data block contains at least the first byte of the given address.

Macros

prefetchdata_hwcache

#define prefetchdata_hwcache(
   addr
) (__builtin_prefetch((addr), 0/*read*/, 3/*put data in all cache levels*/))

Implements hwcache_t.prefetchdata_hwcache.

sizedataprefetch_hwcache

#define sizedataprefetch_hwcache() (16)

Implements hwcache_t.sizedataprefetch_hwcache.

Allows to prefetch data into level 1 cache.
Implements HWCache.
typedef struct hwcache_t hwcache_t
Export hwcache_t into global namespace.
struct hwcache_t
Implicit type allows to access a hardware object.
int unittest_memory_hwcache(void)
Test hwcache_t functionality.
uint32_t sizedataprefetch_hwcache(void)
Size of aligned memory block transfered to and from data cache.
void prefetchdata_hwcache(void *addr)
Prefetches data into all levels of hw cache.
#define prefetchdata_hwcache(
   addr
) (__builtin_prefetch((addr), 0/*read*/, 3/*put data in all cache levels*/))
Implements hwcache_t.prefetchdata_hwcache.
#define sizedataprefetch_hwcache() (16)
Implements hwcache_t.sizedataprefetch_hwcache.
Close