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
tapasco
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
52
Issues
52
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tapasco
tapasco
Commits
44a6271c
Commit
44a6271c
authored
Jul 14, 2017
by
Jens Korinth
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix most whitespace errors
parent
1914aec8
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
161 additions
and
161 deletions
+161
-161
arch/common/include/tapasco.hpp
arch/common/include/tapasco.hpp
+4
-4
arch/common/src/tapasco_functions.c
arch/common/src/tapasco_functions.c
+1
-1
arch/common/tests/tapasco-logging-benchmark/tapasco_logging_benchmark.c
...sts/tapasco-logging-benchmark/tapasco_logging_benchmark.c
+1
-1
arch/common/tests/tapasco_functions_test.c
arch/common/tests/tapasco_functions_test.c
+1
-1
common/src/gen_queue.c
common/src/gen_queue.c
+2
-2
examples/arrayinit/arrayinit-example-mt-ff.cc
examples/arrayinit/arrayinit-example-mt-ff.cc
+1
-1
examples/arrayinit/arrayinit-example-mt.c
examples/arrayinit/arrayinit-example-mt.c
+3
-3
examples/arraysum/arraysum-example-mt-ff.cc
examples/arraysum/arraysum-example-mt-ff.cc
+1
-1
examples/warraw/warraw-example-mt-ff.cc
examples/warraw/warraw-example-mt-ff.cc
+2
-2
examples/warraw/warraw-example-mt.c
examples/warraw/warraw-example-mt.c
+5
-5
kernel/sudoku/src/multithreaded.cpp
kernel/sudoku/src/multithreaded.cpp
+1
-1
kernel/warraw/warraw-tb.c
kernel/warraw/warraw-tb.c
+1
-1
platform/tests/iplatform.c
platform/tests/iplatform.c
+1
-1
platform/tests/platform_slots.c
platform/tests/platform_slots.c
+2
-2
platform/tests/platform_stress_alloc.c
platform/tests/platform_stress_alloc.c
+2
-2
platform/vc709/src/buddy_allocator/buddy_allocator.cpp
platform/vc709/src/buddy_allocator/buddy_allocator.cpp
+57
-57
platform/vc709/src/buddy_allocator/buddy_allocator.hpp
platform/vc709/src/buddy_allocator/buddy_allocator.hpp
+5
-5
platform/vc709/src/buddy_allocator/buddy_tree.cpp
platform/vc709/src/buddy_allocator/buddy_tree.cpp
+40
-40
platform/vc709/src/buddy_allocator/buddy_tree.hpp
platform/vc709/src/buddy_allocator/buddy_tree.hpp
+11
-11
platform/zynq/module/tests/stress-alloc.c
platform/zynq/module/tests/stress-alloc.c
+1
-1
platform/zynq/module/tests/stress-ioctl.c
platform/zynq/module/tests/stress-ioctl.c
+1
-1
platform/zynq/module/zynq_device.c
platform/zynq/module/zynq_device.c
+1
-1
src/main/scala/tapasco/dse/Alternatives.scala
src/main/scala/tapasco/dse/Alternatives.scala
+1
-1
src/test/scala/tapasco/base/ArchitectureTest.scala
src/test/scala/tapasco/base/ArchitectureTest.scala
+2
-2
src/test/scala/tapasco/base/BenchmarkTest.scala
src/test/scala/tapasco/base/BenchmarkTest.scala
+2
-2
src/test/scala/tapasco/base/ConfigurationTest.scala
src/test/scala/tapasco/base/ConfigurationTest.scala
+2
-2
src/test/scala/tapasco/base/CoreTest.scala
src/test/scala/tapasco/base/CoreTest.scala
+2
-2
src/test/scala/tapasco/base/KernelTest.scala
src/test/scala/tapasco/base/KernelTest.scala
+2
-2
src/test/scala/tapasco/base/PlatformTest.scala
src/test/scala/tapasco/base/PlatformTest.scala
+2
-2
src/test/scala/tapasco/filemgmt/BasePathManagerTest.scala
src/test/scala/tapasco/filemgmt/BasePathManagerTest.scala
+1
-1
src/test/scala/tapasco/parser/FeatureParsersSpec.scala
src/test/scala/tapasco/parser/FeatureParsersSpec.scala
+1
-1
src/test/scala/tapasco/reports/TimingReportTest.scala
src/test/scala/tapasco/reports/TimingReportTest.scala
+2
-2
No files found.
arch/common/include/tapasco.hpp
View file @
44a6271c
...
...
@@ -193,7 +193,7 @@ struct Tapasco {
tapasco_device_release_job_id
(
dev_ctx
,
j_id
);
return
res
;
}
/**
* Launches a job on the device and returns a future to the result.
* @param f_id Kernel ID.
...
...
@@ -206,7 +206,7 @@ struct Tapasco {
{
return
async
(
std
::
launch
::
async
,
[
=
,
&
ret
]{
return
launch
(
f_id
,
ret
,
args
...);
});
}
/**
* Launches a job on the device without return value.
* @param f_id Kernel ID.
...
...
@@ -428,7 +428,7 @@ private:
tapasco_device_free
(
dev_ctx
,
h
,
TAPASCO_DEVICE_ALLOC_FLAGS_NONE
);
return
TAPASCO_SUCCESS
;
}
/** Gets a single const pointer argument (dealloc only). **/
template
<
typename
T
>
tapasco_res_t
get_args
(
tapasco_job_id_t
const
j_id
,
uint32_t
const
arg_idx
,
T
const
*
t
)
const
noexcept
...
...
@@ -474,7 +474,7 @@ private:
return
get_args
(
j_id
,
arg_idx
+
1
,
args
...);
}
#endif
bool
_ok
{
false
};
tapasco_ctx_t
*
ctx
{
nullptr
};
tapasco_dev_ctx_t
*
dev_ctx
{
nullptr
};
...
...
arch/common/src/tapasco_functions.c
View file @
44a6271c
...
...
@@ -114,7 +114,7 @@ void tapasco_functions_setup_system(tapasco_dev_ctx_t *dev_ctx, tapasco_function
++
funcs
;
++
slot_id
;
}
}
inline
static
int
reserve_func
(
tapasco_func_t
*
f
,
tapasco_func_id_t
const
f_id
)
{
...
...
arch/common/tests/tapasco-logging-benchmark/tapasco_logging_benchmark.c
View file @
44a6271c
...
...
@@ -200,7 +200,7 @@ int main(int argc, char *argv[])
printf
(
"Average throughput: %10.1f logs/s
\n
"
,
logs
/
(
time_diff
/
1000000
.
0
));
printf
(
"Thread throughput: %10.1f logs/s
\n
"
,
logs
/
(
time_diff
/
1000000
.
0
)
/
(
double
)
thrdcnt
);
free
(
_rnd_data
);
printf
(
"Finished the test.
\n
"
);
tapasco_logging_exit
();
...
...
arch/common/tests/tapasco_functions_test.c
View file @
44a6271c
...
...
@@ -56,7 +56,7 @@ START_TEST (tapasco_functions_check_counts)
fail_if
(
unavail
>=
0
);
tapasco_functions_release
(
funcs
,
slot_id
);
}
tapasco_functions_deinit
(
funcs
);
}
END_TEST
...
...
common/src/gen_queue.c
View file @
44a6271c
...
...
@@ -98,7 +98,7 @@ void gq_enqueue(struct gq_t *q, void *v)
atomic_compare_exchange_strong
(
&
q
->
tail
,
&
tail
,
new
);
}
}
}
TAGGED_PTR
(
n
)
=
{
.
ptr
=
nd
,
.
tag
=
tail
.
tag
+
1
};
atomic_compare_exchange_strong
(
&
q
->
tail
,
&
tail
,
n
);
...
...
@@ -131,7 +131,7 @@ void *gq_dequeue(struct gq_t *q)
TAGGED_PTR
(
new
)
=
{
.
ptr
=
next
.
ptr
,
head
.
tag
+
1
};
if
(
atomic_compare_exchange_strong
(
&
q
->
head
,
&
head
,
new
))
break
;
}
}
}
...
...
examples/arrayinit/arrayinit-example-mt-ff.cc
View file @
44a6271c
...
...
@@ -151,7 +151,7 @@ int main(int argc, char **argv)
std
::
vector
<
ff_node
*>
f
;
for
(
int
i
=
0
;
i
<
sysconf
(
_SC_NPROCESSORS_CONF
);
++
i
)
f
.
push_back
(
new
Worker
);
Emitter
e
;
Collector
c
;
ff_farm
<>
farm
(
f
,
&
e
,
&
c
);
...
...
examples/arrayinit/arrayinit-example-mt.c
View file @
44a6271c
...
...
@@ -81,17 +81,17 @@ static void *runTest(void *p)
// allocate mem on device and copy array part
tapasco_handle_t
h
=
tapasco_device_alloc
(
dev
,
SZ
*
sizeof
(
int
),
0
);
check
(
h
!=
0
);
// get a job id and set argument to handle
tapasco_job_id_t
j_id
=
tapasco_device_acquire_job_id
(
dev
,
11
,
TAPASCO_ACQUIRE_JOB_ID_BLOCKING
);
printf
(
"run %ld: j_id = %d
\n
"
,
run
,
j_id
);
check
(
j_id
>
0
);
check_tapasco
(
tapasco_device_job_set_arg
(
dev
,
j_id
,
0
,
sizeof
(
h
),
&
h
));
// shoot me to the moon!
check_tapasco
(
tapasco_device_job_launch
(
dev
,
j_id
,
TAPASCO_JOB_LAUNCH_BLOCKING
));
// get the result
check_tapasco
(
tapasco_device_copy_from
(
dev
,
h
,
&
arr
[
SZ
*
run
],
SZ
*
sizeof
(
int
),
TAPASCO_COPY_BLOCKING
));
...
...
examples/arraysum/arraysum-example-mt-ff.cc
View file @
44a6271c
...
...
@@ -140,7 +140,7 @@ int main(int argc, char **argv)
std
::
vector
<
ff_node
*>
f
;
for
(
int
i
=
0
;
i
<
sysconf
(
_SC_NPROCESSORS_CONF
);
++
i
)
f
.
push_back
(
new
Worker
);
Emitter
e
;
Collector
c
;
ff_farm
<>
farm
(
f
,
&
e
,
&
c
);
...
...
examples/warraw/warraw-example-mt-ff.cc
View file @
44a6271c
...
...
@@ -156,7 +156,7 @@ int main(int argc, char **argv)
arr
=
(
int
*
)
malloc
(
SZ
*
RUNS
*
sizeof
(
int
));
check
(
arr
!=
NULL
);
init_array
(
arr
,
SZ
*
RUNS
);
golden_arr
=
(
int
*
)
malloc
(
SZ
*
RUNS
*
sizeof
(
int
));
check
(
golden_arr
!=
NULL
);
init_array
(
golden_arr
,
SZ
*
RUNS
);
...
...
@@ -165,7 +165,7 @@ int main(int argc, char **argv)
std
::
vector
<
ff_node
*>
f
;
for
(
int
i
=
0
;
i
<
sysconf
(
_SC_NPROCESSORS_CONF
);
++
i
)
f
.
push_back
(
new
Worker
);
Emitter
e
;
Collector
c
;
ff_farm
<>
farm
(
f
,
&
e
,
&
c
);
...
...
examples/warraw/warraw-example-mt.c
View file @
44a6271c
...
...
@@ -81,23 +81,23 @@ static void *runTest(void *p) {
// golden run
int
golden
=
warraw
(
&
golden_arr
[
SZ
*
run
]);
printf
(
"Golden output for run %ld: %d
\n
"
,
run
,
golden
);
// allocate mem on device and copy array part
tapasco_handle_t
h
=
tapasco_device_alloc
(
dev
,
SZ
*
sizeof
(
int
),
0
);
check
(
h
!=
0
);
check_tapasco
(
tapasco_device_copy_to
(
dev
,
&
arr
[
SZ
*
run
],
h
,
SZ
*
sizeof
(
int
),
TAPASCO_COPY_BLOCKING
));
// get a job id and set argument to handle
tapasco_job_id_t
j_id
=
tapasco_device_acquire_job_id
(
dev
,
12
,
TAPASCO_ACQUIRE_JOB_ID_BLOCKING
);
printf
(
"run %ld: j_id = %d
\n
"
,
run
,
j_id
);
check
(
j_id
>
0
);
check_tapasco
(
tapasco_device_job_set_arg
(
dev
,
j_id
,
0
,
sizeof
(
h
),
&
h
));
// shoot me to the moon!
check_tapasco
(
tapasco_device_job_launch
(
dev
,
j_id
,
TAPASCO_JOB_LAUNCH_BLOCKING
));
// get the result
int32_t
r
=
0
;
check_tapasco
(
tapasco_device_job_get_return
(
dev
,
j_id
,
sizeof
(
r
),
&
r
));
...
...
@@ -127,7 +127,7 @@ int main(int argc, char **argv) {
arr
=
(
int
*
)
malloc
(
SZ
*
RUNS
*
sizeof
(
int
));
check
(
arr
!=
NULL
);
init_array
(
arr
,
SZ
*
RUNS
);
golden_arr
=
(
int
*
)
malloc
(
SZ
*
RUNS
*
sizeof
(
int
));
check
(
golden_arr
!=
NULL
);
init_array
(
golden_arr
,
SZ
*
RUNS
);
...
...
kernel/sudoku/src/multithreaded.cpp
View file @
44a6271c
...
...
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
long
thrdcnt
{
sysconf
(
_SC_NPROCESSORS_CONF
)};
int
c
{
2
};
int
const
mode
{
argc
>
2
&&
argv
[
1
][
0
]
==
'f'
};
if
(
argc
<
3
)
{
cerr
<<
"Usage: sudoku_mt <cpu|fgpa> [<number of threads>] <filename1> <filename2> ..."
<<
endl
;
exit
(
EXIT_FAILURE
);
...
...
kernel/warraw/warraw-tb.c
View file @
44a6271c
...
...
@@ -30,7 +30,7 @@ int main(int argc, char **argv)
int
data
[
SZ
],
i
,
ret
=
0
,
s
=
0
;
for
(
i
=
0
;
i
<
SZ
;
++
i
)
data
[
i
]
=
i
+
1
;
s
=
warraw
(
data
);
for
(
i
=
0
;
i
<
SZ
;
++
i
)
{
...
...
platform/tests/iplatform.c
View file @
44a6271c
...
...
@@ -221,7 +221,7 @@ static int runtest(long const which)
for
(
long
t
=
0
;
t
<
thrdcnt
;
++
t
)
pthread_join
(
threads
[
t
],
NULL
);
platform_deinit
();
return
errors
+
terrors
;
}
...
...
platform/tests/platform_slots.c
View file @
44a6271c
...
...
@@ -104,7 +104,7 @@ int main(int argc, char **argv)
cfg
.
slot_id
=
strtoul
(
argv
[
1
],
NULL
,
0
);
else
cfg
.
slot_id
=
-
1
;
if
(
argc
>
2
)
cfg
.
delay
=
strtoul
(
argv
[
2
],
NULL
,
0
);
else
...
...
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
cfg
.
iterations
=
1
;
cfg
.
mt
=
cfg
.
all_slots
&&
argc
>
4
;
printf
(
"Starting: all_slots = %ld, slot_id = %ld, delay = %ld, iterations = %ld
\n
"
,
cfg
.
all_slots
,
cfg
.
slot_id
,
cfg
.
delay
,
cfg
.
iterations
);
...
...
platform/tests/platform_stress_alloc.c
View file @
44a6271c
...
...
@@ -144,9 +144,9 @@ int main(int argc, char **argv)
pthread_create
(
&
threads
[
t
],
NULL
,
stress
,
(
void
*
)
runs
);
for
(
t
=
0
;
t
<
thread_count
;
++
t
)
pthread_join
(
threads
[
t
],
NULL
);
platform_deinit
();
if
(
!
stop
)
printf
(
"Test successful.
\n
"
);
else
...
...
platform/vc709/src/buddy_allocator/buddy_allocator.cpp
View file @
44a6271c
...
...
@@ -19,20 +19,20 @@
#include "buddy_allocator.hpp"
buddy_allocator
::
buddy_allocator
(
uint32_t
_address
,
uint_fast32_t
_size
,
uint_fast32_t
_min_order
,
uint_fast32_t
_max_order
){
log
(
logDEBUG2
)
<<
"Calculate init values for buddy_tree"
;
min_order
=
_min_order
;
max_order
=
_max_order
;
uint32_t
address
=
calc_Address
(
_address
);
uint_fast32_t
size
=
calc_Size
(
_size
,
address
-
_address
);
log
(
logDEBUG2
)
<<
"Set init values for buddy_tree (size: "
<<
size
<<
") vs. "
<<
calc_Size
(
_size
,
address
-
_address
);
bt
=
new
buddy_tree
(
address
,
size
);
//bt->print_Tree(bt->get_Root());
if
(
!
check_Tree
(
bt
->
get_Root
()))
{
build_Tree
(
bt
->
get_Root
());
error
=
0
;
...
...
@@ -40,13 +40,13 @@ buddy_allocator::buddy_allocator(uint32_t _address, uint_fast32_t _size, uint_fa
log
(
logWARNING
)
<<
"Tree could not be built completely"
;
error
=
-
EINVAL
;
}
//bt->print_Tree(bt->get_Root());
}
buddy_allocator
::~
buddy_allocator
()
{
log
(
logDEBUG2
)
<<
"Delete buddy_tree"
;
delete
(
bt
);
}
...
...
@@ -56,41 +56,41 @@ void buddy_allocator::print_Tree(void) {
}
uint_fast32_t
buddy_allocator
::
dealloc_Mem
(
uint32_t
address
)
{
if
(
error
)
return
-
EINVAL
;
node_t
*
n
=
find_Node
(
address
);
if
(
!
n
)
{
log
(
logWARNING
)
<<
"Node for address "
<<
hex
<<
address
<<
" not found"
<<
dec
;
return
-
EINVAL
;
}
//bt->print_Node(n);
node_t
*
sibling
=
find_Sibling
(
n
);
if
(
bt
->
dealloc_Leaf
(
n
))
{
log
(
logWARNING
)
<<
"Failure in deallocation"
;
return
-
EINVAL
;
}
while
(
sibling
&&
sibling
->
usage
==
nodeFree
&&
n
->
size
<
(
uint_fast32_t
)(
1
<<
max_order
))
{
log
(
logDEBUG2
)
<<
"can merge nodes"
;
node_t
*
parent
=
n
->
parent
;
if
(
bt
->
merge_Node
(
parent
))
{
log
(
logWARNING
)
<<
"Merging gone wrong"
;
}
n
=
parent
;
sibling
=
find_Sibling
(
n
);
}
return
0
;
}
node_t
*
buddy_allocator
::
find_Sibling
(
node_t
*
n
)
{
if
(
n
->
parent
)
{
if
(
n
->
parent
->
l_child
==
n
)
return
n
->
parent
->
r_child
;
...
...
@@ -104,84 +104,84 @@ node_t * buddy_allocator::find_Sibling(node_t * n) {
node_t
*
buddy_allocator
::
find_Node
(
uint32_t
address
)
{
node_t
*
n
=
bt
->
get_Root
();
log
(
logDEBUG2
)
<<
"Search node with matching address "
<<
hex
<<
address
<<
dec
;
//bt->print_Node(n);
while
(
n
!=
NULL
&&
(
n
->
usage
!=
nodeAlloc
||
n
->
address
!=
address
))
{
n
=
bt
->
search_Node
(
n
,
address
);
//bt->print_Node(n);
}
return
n
;
}
uint32_t
buddy_allocator
::
alloc_Mem
(
uint_fast32_t
_size
)
{
if
(
error
)
return
0
;
uint_fast32_t
size
=
fit_Order
(
_size
);
if
(
!
size
)
{
log
(
logINFO
)
<<
"Can't find matching order"
;
return
0
;
}
node_t
*
n
=
find_Free
(
size
);
if
(
!
n
)
{
log
(
logINFO
)
<<
"Can't find matching node"
;
return
0
;
}
//bt->print_Node(n);
n
=
split_Till_Fit
(
n
,
size
);
//bt->print_Node(n);
if
(
bt
->
alloc_Leaf
(
n
))
{
log
(
logWARNING
)
<<
"Allocation gone wrong"
;
return
0
;
}
//bt->print_Tree(bt->get_Root());
return
n
->
address
;
}
node_t
*
buddy_allocator
::
split_Till_Fit
(
node_t
*
_n
,
uint_fast32_t
size
)
{
node_t
*
n
=
_n
;
while
(
n
->
size
>
size
)
{
if
(
!
bt
->
split_Node
(
n
))
{
n
=
n
->
l_child
;
}
else
{
log
(
logWARNING
)
<<
"Splitting gone wrong"
;
}
}
return
n
;
}
node_t
*
buddy_allocator
::
find_Free
(
uint_fast32_t
size
)
{
node_t
*
n
=
bt
->
get_Root
();
bt
->
init_Search
();
log
(
logDEBUG2
)
<<
"Search node with size >= "
<<
size
;
//bt->print_Node(n);
while
(
n
!=
NULL
&&
(
n
->
usage
!=
nodeFree
||
n
->
size
<
size
))
{
n
=
bt
->
search_Node
(
n
);
//bt->print_Node(n);
}
return
n
;
}
uint_fast32_t
buddy_allocator
::
fit_Order
(
uint_fast32_t
_size
)
{
log
(
logDEBUG2
)
<<
"Check if size smaller than max"
;
if
(
_size
>
(
uint_fast32_t
)(
1
<<
max_order
))
{
log
(
logWARNING
)
<<
"Requested size ("
<<
_size
<<
") too large ("
<<
(
1
<<
max_order
)
<<
")"
;
...
...
@@ -191,28 +191,28 @@ uint_fast32_t buddy_allocator::fit_Order(uint_fast32_t _size) {
log
(
logWARNING
)
<<
"Zero memory request"
;
return
0
;
}
uint_fast32_t
size
=
1
;
while
(
size
<
_size
)
{
size
=
size
<<
1
;
}
if
(
size
<
(
uint_fast32_t
)(
1
<<
min_order
))
{
size
=
1
<<
min_order
;
}
log
(
logDEBUG2
)
<<
"New Size: "
<<
size
;
return
size
;
}
uint_fast32_t
buddy_allocator
::
build_Tree
(
node_t
*
n
)
{
if
(
n
->
size
>
(
uint_fast32_t
)(
1
<<
max_order
))
{
log
(
logDEBUG1
)
<<
"Has to be split"
;
if
(
!
bt
->
split_Node
(
n
))
{
log
(
logDEBUG2
)
<<
"success - do it recursivly"
;
build_Tree
(
n
->
l_child
);
...
...
@@ -220,47 +220,47 @@ uint_fast32_t buddy_allocator::build_Tree(node_t *n) {
}
else
log
(
logWARNING
)
<<
"something went wrong"
;
}
return
0
;
}
uint_fast32_t
buddy_allocator
::
check_Tree
(
node_t
*
n
)
{
log
(
logDEBUG2
)
<<
"Check if address wraparounds with size offset"
;
if
(
n
->
size
+
n
->
address
<
n
->
address
)
{
log
(
logERROR
)
<<
"Size is too large for address"
;
return
-
EINVAL
;
}
log
(
logDEBUG2
)
<<
"Check min and max order values"
;
if
(
max_order
<
min_order
)
{
log
(
logERROR
)
<<
"Min_Order larger than Max_Order"
;
return
-
EINVAL
;
}
log
(
logDEBUG2
)
<<
"Check min and max order values upper bounds"
;
if
(
min_order
>
31
||
max_order
>
31
)
{
log
(
logERROR
)
<<
"Orders too large for 32 bit space"
;
return
-
EINVAL
;
}
log
(
logDEBUG2
)
<<
"Check min and max order values under bounds"
;
if
(
min_order
==
0
||
max_order
==
0
)
{
log
(
logERROR
)
<<
"Order is Zero"
;
return
-
EINVAL
;
}
log
(
logDEBUG2
)
<<
"Check if at least one chunk can be built"
;
if
(
n
->
size
<
(
uint_fast32_t
)(
1
<<
min_order
))
{
log
(
logERROR
)
<<
"Size too small for requested Min_Order"
;
return
-
EINVAL
;
}
return
0
;
}
uint32_t
buddy_allocator
::
calc_Address
(
uint32_t
a
)
{
if
((
a
&
(
ALIGNMENT
-
1
))
!=
0
)
{
log
(
logDEBUG2
)
<<
hex
<<
(
a
&
~
(
ALIGNMENT
-
1
))
+
ALIGNMENT
<<
dec
;
return
(
a
&
~
(
ALIGNMENT
-
1
))
+
ALIGNMENT
;
...
...
@@ -271,19 +271,19 @@ uint32_t buddy_allocator::calc_Address(uint32_t a) {
}
uint_fast32_t
buddy_allocator
::
calc_Size
(
uint_fast32_t
s
,
uint32_t
diff
)
{
log
(
logDEBUG2
)
<<
dec
<<
"Old Size: "
<<
s
<<
" Diff: "
<<
diff
;
uint_fast32_t
order
=
1
;
uint_fast32_t
size
=
s
-
diff
;
while
(
order
<=
size
)
{
order
=
order
<<
1
;
}
if
(
size
==
0
||
order
==
1
)
{
log
(
logWARNING
)
<<
" No bytes left for Allocator"
;
}
return
order
>>
1
;
}
platform/vc709/src/buddy_allocator/buddy_allocator.hpp
View file @
44a6271c
...
...
@@ -34,24 +34,24 @@ class buddy_allocator
public:
buddy_allocator
(
uint32_t
,
uint_fast32_t
,
uint_fast32_t
,
uint_fast32_t
);
~
buddy_allocator
();
uint32_t
alloc_Mem
(
uint_fast32_t
);
uint_fast32_t
dealloc_Mem
(
uint32_t
);
void
print_Tree
(
void
);
private:
buddy_tree
*
bt
;
uint_fast32_t
min_order
;
uint_fast32_t
max_order
;
uint_fast32_t
error
;
uint32_t
calc_Address
(
uint32_t
);
uint_fast32_t
calc_Size
(
uint_fast32_t
,
uint32_t
);
uint_fast32_t
build_Tree
(
node_t
*
);
uint_fast32_t
check_Tree
(
node_t
*
);
node_t
*
find_Free
(
uint_fast32_t
);
node_t
*
find_Node
(
uint32_t
);
node_t
*
find_Sibling
(
node_t
*
);
...
...
platform/vc709/src/buddy_allocator/buddy_tree.cpp
View file @
44a6271c
...
...
@@ -19,75 +19,75 @@
#include "buddy_tree.hpp"
buddy_tree
::
buddy_tree
(
uint32_t
_address
,
uint_fast32_t
_size
){
log
(
logDEBUG2
)
<<
"Set init values for root (size: "
<<
_size
<<
")"
;
root
=
new
node_t
(
_address
,
_size
,
NULL
);
search_last
=
NULL
;
search_direction
=
nodeLeft
;
nodes
=
leaves
=
1
;
}
buddy_tree
::~
buddy_tree
()
{
log
(
logDEBUG2
)
<<
"Delete root node"
;
delete
(
root
);
}
uint_fast32_t
buddy_tree
::
split_Node
(
node_t
*
n
)
{
log
(
logDEBUG2
)
<<
"Check if it has any childs"
;
if
(
n
->
l_child
!=
NULL
||
n
->
r_child
!=
NULL
)
{
// redundant check, if node->usage is correctly used
log
(
logERROR
)
<<
"Contains childs - stop"
;
return
-
EINVAL
;
}
log
(
logDEBUG2
)
<<
"Check if it is really free"
;
if
(
n
->
usage
!=
nodeFree
)
{
log
(
logERROR
)
<<
"In use - stop"
;
return
-
EINVAL
;
}