Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CTA-LAPP
PHOENIX_LIBS
PhoenixHPCProxy
Commits
3b8b2f9c
Commit
3b8b2f9c
authored
Dec 12, 2020
by
Pierre Aubert
Browse files
First full proxy generation test ok for compilation
parent
01d49a1d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
18 deletions
+45
-18
TESTS/TEST_BASE_HEADER/testHeaderMacro.h
TESTS/TEST_BASE_HEADER/testHeaderMacro.h
+2
-2
TESTS/TEST_BASE_HEADER/testHeaderMacroSize.h
TESTS/TEST_BASE_HEADER/testHeaderMacroSize.h
+9
-0
src/BackEnd/backend_proxy_loader.cpp
src/BackEnd/backend_proxy_loader.cpp
+7
-6
src/FrontEnd/HeaderParser.cpp
src/FrontEnd/HeaderParser.cpp
+26
-9
src/main.cpp
src/main.cpp
+1
-1
No files found.
TESTS/TEST_BASE_HEADER/testHeaderMacro.h
View file @
3b8b2f9c
...
...
@@ -2,8 +2,8 @@
#ifndef __PRINT_ARCH_H__
#define __PRINT_ARCH_H__
void
print_arch
(
const
char
*
str
);
// __restrict__
void
print_arch
(
const
char
*
__restrict__
str
);
#endif
TESTS/TEST_BASE_HEADER/testHeaderMacroSize.h
0 → 100644
View file @
3b8b2f9c
#ifndef __PRINT_ARCH_H__
#define __PRINT_ARCH_H__
// __restrict__
void
print_arch
(
const
char
*
__restrict__
str
,
long
unsigned
int
size
);
#endif
src/BackEnd/backend_proxy_loader.cpp
View file @
3b8b2f9c
...
...
@@ -117,9 +117,9 @@ std::string cpp_backendProxyLoaderParseArchFileSource(const PVecArchLib & vecArc
body
+=
"
\t\t
return false;
\n
"
;
body
+=
"
\t
}
\n
"
;
body
+=
"
\t
//Let's get the file size
\n
"
;
body
+=
"
\t
fseek(f
s
, 0, SEEK_END);
\n
"
;
body
+=
"
\t
size_t fileSize(ftell(f
s
));
\n
"
;
body
+=
"
\t
fseek(f
s
, 0, SEEK_SET);
\n
"
;
body
+=
"
\t
fseek(f
p
, 0, SEEK_END);
\n
"
;
body
+=
"
\t
size_t fileSize(ftell(f
p
));
\n
"
;
body
+=
"
\t
fseek(f
p
, 0, SEEK_SET);
\n
"
;
body
+=
"
\t
if(fileSize == 0lu){
\n
"
;
body
+=
"
\t\t
return false;
\n
"
;
body
+=
"
\t
}
\n
"
;
...
...
@@ -128,9 +128,9 @@ std::string cpp_backendProxyLoaderParseArchFileSource(const PVecArchLib & vecArc
body
+=
"
\t
//And load the file
\n
"
;
body
+=
"
\t
if(fread(procCpuInfo, sizeof(char), fileSize, fp) != fileSize){return false;}
\n
"
;
body
+=
"
\t
//Let's check the avalaible architectures
\n
"
;
std
::
string
strElse
(
""
);
std
::
string
strElse
(
"
\t
"
);
for
(
PVecArchLib
::
const_reverse_iterator
it
(
vecArchLib
.
rbegin
());
it
!=
vecArchLib
.
rend
();
++
it
){
body
+=
"
\t
"
+
strElse
+
"if(strstr(procCpuInfo,
\"
"
+
it
->
getArchitecture
()
+
"
\"
) != NULL){
\n
"
;
body
+=
strElse
+
"if(strstr(procCpuInfo,
\"
"
+
it
->
getArchitecture
()
+
"
\"
) != NULL){
\n
"
;
std
::
string
libName
(
getFileName
(
it
->
getName
()));
body
+=
"
\t\t
load(
\"
"
+
libName
+
"
\"
);
\n
"
;
body
+=
"
\t
}"
;
...
...
@@ -217,7 +217,8 @@ std::string cpp_backendProxyLoaderSource(const PVecSource & vecSource, const PVe
std
::
string
body
(
cpp_licenceSaveStr
());
body
+=
"#include <stdio.h>
\n
"
;
body
+=
"#include <stdlib.h>
\n
"
;
body
+=
"#include <dlfcn.h>
\n\n
"
;
body
+=
"#include <dlfcn.h>
\n
"
;
body
+=
"#include <string.h>
\n\n
"
;
for
(
PVecSource
::
const_iterator
it
(
vecSource
.
begin
());
it
!=
vecSource
.
end
();
++
it
){
body
+=
"#include
\"
"
+
it
->
getName
()
+
"
\"\n
"
;
...
...
src/FrontEnd/HeaderParser.cpp
View file @
3b8b2f9c
...
...
@@ -61,6 +61,7 @@ bool HeaderParser::parseFile(){
PFunction
function
;
if
(
parseDocString
()){}
else
if
(
p_parser
->
isMatch
(
"//"
)){
p_parser
->
getUntilKeyWithoutPatern
(
"
\n
"
);}
//Skip comment
else
if
(
p_parser
->
isMatch
(
"/*"
)){
p_parser
->
getUntilKeyWithoutPatern
(
"*/"
);}
//Skip comment
else
if
(
parseMacro
()){}
else
if
(
parseFunction
(
function
)){
p_currentSource
.
getVecFunction
().
push_back
(
function
);
...
...
@@ -142,7 +143,7 @@ bool HeaderParser::parseFunction(PFunction & function){
std
::
string
templateDef
(
""
),
returnType
(
""
);
parseTemplateDef
(
templateDef
);
parseType
(
returnType
);
std
::
cerr
<<
"HeaderParser::parseFunction : returnType = '"
<<
returnType
<<
"'"
<<
std
::
endl
;
std
::
string
functionName
(
p_parser
->
getNextToken
());
if
(
functionName
==
""
){
return
false
;}
//This is not a function
function
.
setDocString
(
p_lastDocString
);
...
...
@@ -155,14 +156,21 @@ bool HeaderParser::parseFunction(PFunction & function){
PArgument
arg
;
if
(
parseDocString
()){}
else
if
(
p_parser
->
isMatch
(
"//"
)){
p_parser
->
getUntilKeyWithoutPatern
(
"
\n
"
);}
//Skip comment
else
if
(
p_parser
->
isMatch
(
"/*"
)){
p_parser
->
getUntilKeyWithoutPatern
(
"*/"
);}
//Skip comment
else
if
(
parseArgument
(
arg
)){
function
.
getVecArgument
().
push_back
(
arg
);
if
(
!
p_parser
->
isMatch
(
","
)
&&
!
isMatchRewind
(
")"
)){
errorAt
();
std
::
cerr
<<
"HeaderParser::parseFunction : expect ',' or ')' after function definition '"
<<
functionName
<<
"'"
<<
std
::
endl
;
return
true
;
}
}
else
{
errorAt
();
std
::
cerr
<<
"HeaderParser::parseFunction : cannot parse attribute"
<<
std
::
endl
;
return
true
;
}
p_parser
->
skipWhiteSpace
();
}
if
(
!
p_parser
->
isMatch
(
";"
)){
errorAt
();
...
...
@@ -201,6 +209,14 @@ void HeaderParser::parseTemplateDef(std::string & templateDef){
templateDef
+=
">"
;
}
///Say if the given string is a pointer or a reference
/** @param str : string to be analysed
* @return true if the given string is a pointer or a reference, false otherwise
*/
bool
isPtrRef
(
const
std
::
string
&
str
){
return
findCharsInString
(
str
,
"&*"
)
||
str
==
"__restrict__"
;
}
///Parse a PAttribute
/** @param[out] arg : PArgument to be parsed
* @return true on success, false otherwise
...
...
@@ -213,21 +229,22 @@ bool HeaderParser::parseArgument(PArgument & arg){
std
::
string
varName
(
""
),
ptrRef
(
""
),
tmpPtrRef
(
""
);
tmpPtrRef
=
p_parser
->
getNextToken
();
// ptrRef = p_parser->getNextToken();
if
(
findCharsInString
(
tmpPtrRef
,
"&*"
)
/* || tmpPtrRef == "__restrict__"*/
){
while
(
findCharsInString
(
tmpPtrRef
,
"&*"
)
/* || tmpPtrRef == "__restrict__"*/
){
if
(
isPtrRef
(
tmpPtrRef
)){
do
{
ptrRef
+=
tmpPtrRef
;
tmpPtrRef
=
p_parser
->
getNextToken
();
// if(tmpPtrRef == "__restrict__"){ptrRef += " ";}
ptrRef
+=
tmpPtrRef
;
}
varName
=
p_parser
->
getNextToken
();
}
while
(
isPtrRef
(
tmpPtrRef
));
varName
=
tmpPtrRef
;
}
else
{
ptrRef
=
tmpPtrRef
;
varName
=
ptrRef
;
ptrRef
=
""
;
}
std
::
cerr
<<
"HeaderParser::parseArgument :
varNam
e = '"
<<
varNam
e
<<
"
'
, ptrRef = '"
<<
ptrRef
<<
"'"
<<
std
::
endl
;
std
::
cerr
<<
"HeaderParser::parseArgument :
typ
e = '"
<<
typ
e
<<
", ptrRef = '"
<<
ptrRef
<<
"'
, varName = '"
<<
varName
<<
"'
"
<<
std
::
endl
;
std
::
string
defaultValue
(
""
);
if
(
p_parser
->
isMatch
(
"="
)){
//Some default value
defaultValue
=
p_parser
->
getNextToken
();
...
...
@@ -253,7 +270,7 @@ bool HeaderParser::parseArgument(PArgument & arg){
void
HeaderParser
::
parseType
(
std
::
string
&
type
){
type
=
""
;
std
::
string
token
(
p_parser
->
getNextToken
());
while
(
token
==
"const"
||
token
==
"unsigned"
||
token
==
"long"
/* || findCharsInString(token, "&*")*/
){
while
(
token
==
"const"
||
token
==
"unsigned"
||
token
==
"long"
){
type
+=
token
+
" "
;
token
=
p_parser
->
getNextToken
();
}
...
...
src/main.cpp
View file @
3b8b2f9c
...
...
@@ -134,7 +134,7 @@ int main(int argc, char** argv){
defaultMode
.
getValue
(
libName
,
"library"
);
PVecArchLib
vecArchLib
;
//
parseVecArchLib(vecArchLib, defaultMode);
parseVecArchLib
(
vecArchLib
,
defaultMode
);
return
processFiles
(
listInputFile
,
libName
,
vecArchLib
,
outputDir
);
}
...
...
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