Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tapasco
tapasco
Commits
96dc8327
Commit
96dc8327
authored
Jun 02, 2017
by
Jens Korinth
Browse files
Update rot13 kernel
parent
b89ccf99
Changes
3
Hide whitespace changes
Inline
Side-by-side
kernel/rot13/CMakeLists.txt
View file @
96dc8327
...
...
@@ -6,5 +6,5 @@ link_directories("$ENV{TAPASCO_HOME}/arch/axi4mm/lib/${CMAKE_SYSTEM_PROCESSOR}"
add_executable
(
rot13 rot13.cpp
)
add_executable
(
tapasco-rot13 tapasco_rot13.cpp
)
target_link_libraries
(
tapasco-rot13 platform tapasco atomic
)
target_link_libraries
(
tapasco-rot13 platform tapasco atomic
pthread
)
set_target_properties
(
rot13 tapasco-rot13 PROPERTIES COMPILE_FLAGS
"-Wall -std=c++11 -g"
)
kernel/rot13/rot13.cpp
View file @
96dc8327
...
...
@@ -30,7 +30,7 @@ using namespace std;
static
constexpr
size_t
MAX_LEN
=
4096
;
static
inline
char
test
rot13
(
const
char
c
)
static
inline
char
char_
rot13
(
const
char
c
)
{
if
(
c
<
'A'
||
c
>
'Z'
)
return
c
;
return
c
>=
'N'
?
c
-
13
:
c
+
13
;
...
...
@@ -42,7 +42,7 @@ void rot13(uint32_t const len, char const text_in[MAX_LEN],
char
buf_in
[
MAX_LEN
],
buf_out
[
MAX_LEN
];
memcpy
(
buf_in
,
text_in
,
len
);
for
(
size_t
i
=
0
;
i
<
len
;
++
i
)
buf_out
[
i
]
=
test
rot13
(
buf_in
[
i
]);
buf_out
[
i
]
=
char_
rot13
(
buf_in
[
i
]);
memcpy
(
text_out
,
buf_out
,
len
);
}
...
...
kernel/rot13/tapasco_rot13.cpp
View file @
96dc8327
...
...
@@ -59,14 +59,14 @@ static char *read_file(char const *fn, size_t& file_sz)
int
main
(
int
argc
,
char
*
argv
[])
{
size_t
sz
;
assert
(
argc
>
1
);
// need filename
Tapasco
tapasco
;
// init T
PC
char
*
filedata
=
read_file
(
argv
[
1
],
sz
);
// read data
assert
(
argc
>
1
);
// need filename
Tapasco
tapasco
;
// init T
apasco
char
*
filedata
=
read_file
(
argv
[
1
],
sz
);
// read data
atomic
<
long
>
nr_jobs
{
static_cast
<
long
>
(
sz
/
MAX_LEN
+
(
sz
%
MAX_LEN
?
1
:
0
))
};
// number of jobs
size_t
const
nr_threads
=
tapasco
.
func_instance_count
(
13
);
// number PEs
vector
<
future
<
void
>
>
fs
;
// futures
char
*
text_out
=
new
char
[
sz
];
// out buffer
(
sz
/
MAX_LEN
+
(
sz
%
MAX_LEN
?
1
:
0
))
};
// number of jobs
size_t
const
nr_threads
=
tapasco
.
func_instance_count
(
13
);
// number PEs
vector
<
future
<
void
>
>
fs
;
// futures
char
*
text_out
=
new
char
[
sz
];
// out buffer
for
(
size_t
i
=
0
;
i
<
nr_threads
;
++
i
)
{
fs
.
push_back
(
async
(
launch
::
async
,
[
&
]()
{
...
...
@@ -93,7 +93,6 @@ int main(int argc, char *argv[])
for
(
auto
&
f
:
fs
)
f
.
get
();
// wait for threads to finish
cout
<<
text_out
<<
endl
;
delete
[]
text_out
;
delete
[]
filedata
;
...
...
Jens Korinth
@jk
mentioned in commit
a831b501
·
Jul 14, 2017
mentioned in commit
a831b501
mentioned in commit a831b5015df6bd8f8d23ddd334a3b1159392de92
Toggle commit list
Write
Preview
Supports
Markdown
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