ROSE 編譯器框架/OpenMP 支援
官方文件
- ROSE 手冊有一章(第 12 章 OpenMP 支援)解釋了詳細資訊。 pdf
- 一篇論文發表了 ROSE OpenMP 實現的獨特性 pdf
- 一篇關於加速器 (GPU) 支援的論文:“使用 OpenMP 加速器模型的早期經驗。”
ROSE 支援 C/C++ 的 OpenMP 3.0(以及有限的 Fortran 支援),並且有一個來自 OpenMP 4.0 的實驗性 OpenMP 加速器模型實現
與前端() 的連線點位於 sage_support.cpp 中,透過 SgFile::secondaryPassOverSourceFile() 呼叫的 OmpSupport::processOpenMP()
void processOpenMP(SgSourceFile *sageFilePtr) of ompAstConstruction.cpp // ROSE 中 OpenMP 處理的頂級驅動程式
- 前端解析原始檔 (ompparser.yy 和 ompFortranParser.C) 位於 https://github.com/rose-compiler/rose/tree/master/src/frontend/SageIII 下
- void build_OpenMP_AST(SgSourceFile *sageFilePtr) of ompAstConstruction.cpp // 處理編譯指示併為 OpenMP 構建 AST
- void attachOmpAttributeInfo(SgSourceFile *sageFilePtr) of ompAstConstruction.cpp // 查詢並解析 OpenMP 編譯指示為 OmpAttribute 資訊。
- convert_OpenMP_pragma_to_AST() // 將屬性轉換為專用 OpenMP AST 節點
- void build_OpenMP_AST(SgSourceFile *sageFilePtr) of ompAstConstruction.cpp // 處理編譯指示併為 OpenMP 構建 AST
- 將 OpenMP 轉換為執行緒程式碼的轉換位於 omp_lowering.cpp 中,位於 https://github.com/rose-compiler/rose/blob/master/src/midend/programTransformation/ompLowering
- lower_omp()
- OpenMP 執行時介面在上述同一 ompLowering 目錄下的 libxomp.h 和 xomp.c 中定義
- GCC 的 OpenMP 執行時庫 libgomp 與此實現一起使用。
- 可以選擇使用其他執行時庫,例如 Omni 執行時庫,與 ROSE 連線。但這種支援沒有得到積極維護。
OpenMP 處理發生在 rose/src/frontend/SageIII/sage_support/sage_support.cpp 中的 void SgFile::secondaryPassOverSourceFile() 中。此階段收集有關原始檔的額外資訊,例如註釋、預處理指令等。
配置:在配置 ROSE 時,請始終嘗試使用 --with-gomp_omp_runtime_library=/usr/apps/gcc/4.4.1/lib64/。因此,生成的 ROSE 翻譯器可以自動連結到 libgomp.a 來為您生成可執行檔案。這也將允許執行 omp Lowering 的執行測試以捕獲錯誤。沒有此選項,只有編譯級別測試會執行。
與所有其他支援 OpenMP 的編譯器一樣,您必須使用 -rose:openmp:lowering 顯式啟用此支援,例如
identityTranslator -rose:openmp:lowering your_openmp_code.c
此選項告訴 ROSE 翻譯器識別 OpenMP 編譯指示並將輸入轉換為使用 libgomp 執行時庫。透過使用詳細標誌,可以檢視編譯、後端編譯器和連結的詳細命令列。
identityTranslator -rose:openmp:lowering -rose:verbose 3 your_openmp_code.c
此詳細模式下將顯示三個內部步驟
- ROSE 翻譯器的翻譯:identityTranslator -rose:openmp:lowering -rose:verbose 3 ...-DUSE_ROSE --c -D_OPENMP your_openmp_code.c
- 後端編譯器編譯:gcc -DUSE_ROSE -D_OPENMP -I/export/tmp.liao6/workspace/masterClean/build64/install/include rose_your_openmp_code.c -c -o mg_your_openmp_code.o
- 連結:gcc your_openmp_code.o -lm /export/tmp.liao6/workspace/masterClean/build64/install/lib/libxomp.a /usr/apps/gcc/4.4.1/lib64//libgomp.a -lpthread
有關 OpenMP 支援的更多命令列選項選擇
- -rose:OpenMP, -rose:openmp 遵循 OpenMP 3.0 針對 C/C++ 和 Fortran 的規範,執行以下操作之一
- -rose:OpenMP:parse_only, -rose:openmp:parse_only 將 OpenMP 指令解析為 OmpAttributes,不執行其他操作(現在的預設行為)
- -rose:OpenMP:ast_only, -rose:openmp:ast_only 在 -rose:openmp:parse_only 之上,從 OmpAttributes 構建 OpenMP AST 節點,不執行其他操作
- -rose:OpenMP:lowering, -rose:openmp:lowering 在 -rose:openmp:ast_only 之上,將具有 OpenMP 節點的 AST 轉換為針對 GCC GOMP 執行時庫的多執行緒程式碼
編譯
- ./identityTranslator -I../../../../../../rose-develop/src/frontend/SageIII -I../../../../../../rose-develop/src/midend/programTransformation/ompLowering -I../../../../.. -rose:openmp:lowering -g --edg:no_warnings -c ../../../../../../rose-develop/tests/nonsmoke/functional/CompileTests/OpenMP_tests/pi.c
連結
gcc pi.o -o pi.out -L../../../../../src/midend -lxomp /usr/lib/gcc/x86_64-linux-gnu/4.9//libgomp.a -lpthread -lm
測試
- ROSE 中大約有 70 個內建執行測試(許多測試具有自我驗證)。
- OpenMP 解析測試:tests/CompileTests/OpenMP_tests
- OpenMP 翻譯和執行測試:rose/tests/roseTests/ompLoweringTests,需要 --with-gomp_omp_runtime_library=/usr/apps/gcc/4.4.x(或更高版本)/lib64/ 來連結並執行測試。
一些基準測試用於在 Jenkins(我們的迴歸測試伺服器)中測試 ROSE 中的 OpenMP 支援
- a22b-NPB-2.3-C-parallel:所有 8 個基準測試透過
- a21-SPEC-OMP-64bit-parallel:3 個基準測試透過。
- LULESH OpenMP 版本:下載
對於內建測試
- 原始檔位於:https://github.com/rose-compiler/rose/tree/master/tests/nonsmoke/functional/CompileTests/OpenMP_tests
- 測試驅動程式在 https://github.com/rose-compiler/rose/tree/master/tests/nonsmoke/functional/roseTests/ompLoweringTests/Makefile.am 中定義。檢視 C_TESTCODES_REQUIRED_TO_RUN 下的檔案列表。
如果要讓它們在鍵入“make check”時自動執行,您必須配置 GOMP 的路徑。例如,../sourcetree ... --with-gomp_omp_runtime_library=/usr/apps/gcc/4.4.1/lib64/
前端解析原始檔 (ompparser.yy 和 ompFortranParser.C) 位於 https://github.com/rose-compiler/rose/tree/master/src/frontend/SageIII 下
- C/C++ 指令使用 Flex/Bison 解析
- Fortran 指令透過手工編寫的遞迴下降解析器解析 https://github.com/rose-compiler/rose/blob/master/src/frontend/SageIII/ompFortranParser.C
- 呼叫解析器的驅動程式:來自 https://github.com/rose-compiler/rose/blob/master/src/frontend/SageIII/ompAstConstruction.cpp 的 void processingOpenMP(SgSoureFile*)
- void attachOmpAttributeInfo(SgSourceFile *sageFilePtr) // 呼叫 parse_fortran_openmp()
要識別一個新關鍵字,例如一個子句:target ()
- 在 ompparser.yy 中新增一個令牌名稱:%token TARGET
- 在 omplexer.ll 中解析令牌:target {return cond_return ( TARGET ); }
- 在 ompparser.yy 中新增語法規則
openmp_directive : parallel_directive
...
| target_directive
....
target_directive: /* #pragma */ OMP TARGET {
ompattribute = buildOmpAttribute(e_target,gNode,true);
omptype = e_target;
}
target_clause_optseq
;
解析結果儲存到持久 AST 屬性中。使用名為 OmpAttribute 的派生型別。
./src/frontend/SageIII/OmpAttribute.h /.C
AST 對 OpenMP 的支援
[edit | edit source]我們定義了一組專門的 AST 節點來表示原始碼中的 OpenMP 指令。例如,您可以使用 dotGeneratorWholeASTGraph 檢視示例輸入程式碼的 AST
/* A kernel for two level parallelizable loop with reduction */
float u[100][100];
float foo ()
{
int i,j;
float temp, error;
#pragma omp parallel for private (temp,i,j) reduction (+:error)
for (i = 0; i < 100; i++)
for (j = 0; j < 100; j++)
{
temp = u[i][j];
error = error + temp * temp;
}
return error;
}
./dotGeneratorWholeASTGraph -c -rose:OpenMP:ast_only reduction_1.c
生成的 dot 圖將包含以下節點
- SgBasicBlock // 函式定義的基本塊
- SgOmpParallelStatement // AST 中專門的 OpenMP 並行語句
- SgOmpForStatement // 專門的 Omp for 語句。它有 SgOmpReductionClause 和 SgOmpPrivateClause,透過 ->get_clauses() 獲得
- SgForStatement // 受 "omp parallel for" 影響的實際迴圈
- SgOmpForStatement // 專門的 Omp for 語句。它有 SgOmpReductionClause 和 SgOmpPrivateClause,透過 ->get_clauses() 獲得
- SgOmpParallelStatement // AST 中專門的 OpenMP 並行語句
組合指令(如 "omp parallel for")被拆分為兩個指令 "omp parallel" 和 "omp for"。所有子句儘可能地附加到內部指令。這是為了支援以後更簡單的處理(例如在 OpenMP 降級中)。
- 注意:目前還沒有針對組合指令的專用 AST 節點。但如果需要,我們可以新增它們。
Omp 節點
[edit | edit source]OpenMP AST 節點列表如下(來自 http://rosecompiler.org/ROSE_HTML_Reference/annotated.html)
- SgOmpAlignedClause
- SgOmpAtomicStatement
- SgOmpBarrierStatement
- SgOmpBeginClause
- SgOmpBodyStatement
- SgOmpClause
- SgOmpClauseBodyStatement
- SgOmpCollapseClause
- SgOmpCopyinClause
- SgOmpCopyprivateClause
- SgOmpCriticalStatement
- SgOmpDefaultClause
- SgOmpDeviceClause
- SgOmpDoStatement
- SgOmpEndClause
- SgOmpExpressionClause
- SgOmpFirstprivateClause
- SgOmpFlushStatement
- SgOmpForStatement
- SgOmpIfClause
- SgOmpLastprivateClause
- SgOmpLinearClause
- SgOmpMapClause
- SgOmpMasterStatement
- SgOmpNowaitClause
- SgOmpNumThreadsClause
- SgOmpOrderedClause
- SgOmpOrderedStatement
- SgOmpParallelStatement
- SgOmpPrivateClause
- SgOmpReductionClause
- SgOmpSafelenClause
- SgOmpScheduleClause
- SgOmpSectionsStatement
- SgOmpSectionStatement
- SgOmpSharedClause
- SgOmpSimdStatement
- SgOmpSingleStatement
- SgOmpTargetDataStatement
- SgOmpTargetStatement
- SgOmpTaskStatement
- SgOmpTaskwaitStatement
- SgOmpThreadprivateStatement
- SgOmpUniformClause
- SgOmpUntiedClause
- SgOmpVariablesClause
- SgOmpWorkshareStatement
請參考 Doxygen 文件瞭解成員訪問函式。
AST 圖
[edit | edit source]要檢視輸入 OpenMP 程式碼的 AST 圖,您應該使用 dotGraphGeneratorWhole 或 pdfGenerator。
一個示例 dot 圖可在 parallefor.dot.png 中找到,該檔案位於 https://github.com/chunhualiao/rose-ast 中。
訪問 OpenMP 子句和變數
[edit | edit source]請參考 Doxygen 文件瞭解 SgOmp* 節點的成員訪問函式。
許多輔助函式在 OmpSupport 名稱空間中定義,如 http://rosecompiler.org/ROSE_HTML_Reference/namespaceOmpSupport.html 所示
- https://github.com/rose-compiler/rose/blob/master/src/frontend/SageIII/OmpAttribute.h
- https://github.com/rose-compiler/rose/blob/master/src/midend/programTransformation/ompLowering/omp_lowering.h
如何訪問這些節點資訊的最佳示例在 ROSE 的 OpenMP 降級步驟中。
例如,要獲取 threadprivate 子句中的變數引用列表,程式碼如下所示
void transOmpThreadprivate(SgNode * node)
{
ROSE_ASSERT(node != NULL );
SgOmpThreadprivateStatement* target = isSgOmpThreadprivateStatement(node);
ROSE_ASSERT(target != NULL );
SgVarRefExpPtrList nameList = target->get_variables ();
for (size_t i = 0; i<nameList.size(); i++)
{
SgInitializedName* init_name = nameList[i]->get_symbol()->get_declaration();
ROSE_ASSERT(init_name != NULL);
SgVariableDeclaration* decl = isSgVariableDeclaration(init_name-> get_declaration());
ROSE_ASSERT (decl != NULL);
....
}
....
}
另一個示例檢查變數是否在某些 OpenMP 子句的變數列表中
#include "rose.h"
#include "omp_lowering.h" // many helper functions are declared here
using namespace OmpSupport;
...
SgInitializedName* orig_var = ... ;
SgOmpClauseBodyStatement* clause_stmt = isSgOmpClauseBodyStatement(ompStmt);
// check if orig_var is within the specified clauses of an OpenMP statement (e.g. omp for)
VariantVector vvt (V_SgOmpPrivateClause);
vvt.push_back(V_SgOmpReductionClause);
vvt.push_back(V_SgOmpFirstprivateClause);
vvt.push_back(V_SgOmpLastprivateClause);
if (isInClauseVariableList(orig_var, clause_stmt, vvt))
{
...
}
// another one: check if a loop index variable is already in private() or not
isPrivateInRegion = isInClauseVariableList(index_var, isSgOmpClauseBodyStatement(omp_stmt), V_SgOmpPrivateClause);
// add loop index variable into the private() clause
addClauseVariable(index_var,isSgOmpClauseBodyStatement(omp_loop), V_SgOmpPrivateClause);
查詢資料共享屬性
[edit | edit source]有一個介面函式可以查詢 OpenMP 程式中引用的變數的資料共享屬性,該函式在 https://github.com/rose-compiler/rose/blob/master/src/midend/programTransformation/ompLowering/omp_lowering.h 中宣告
namespace OmpSupport {
//! Return the data sharing attribute type of a variable, specified as a symbol and an anchor node
//! (Must be the inner most node associated with the variable reference, e.g. a SgVarRefExp, SgVariableDeclaration, etc)
//! Possible returned values include: e_shared, e_private, e_firstprivate, e_lastprivate, e_reduction,
//! e_threadprivate, e_copyin, and e_copyprivate.
ROSE_DLL_API omp_construct_enum getDataSharingAttribute (SgSymbol* var, SgNode* anchor_node);
//! Return the OpenMP data sharing attribute type of a variable reference
ROSE_DLL_API omp_construct_enum getDataSharingAttribute (SgVarRefExp* varRef);
...
}
測試/示例程式碼
#include <vector>
#include "OmpSupport.h" // this file includes several headers declaring OmpSupport namespace
using namespace std;
using namespace OmpSupport;
using namespace SageInterface;
class visitorTraversal : public AstSimpleProcessing
{
protected:
virtual void visit(SgNode* n);
};
void visitorTraversal::visit(SgNode* node)
{
if (SgLocatedNode* lnode = isSgLocatedNode(node))
{
//skip system headers
if (insideSystemHeader (lnode))
return;
if (SgForStatement* forloop= isSgForStatement(node))
{
cout<<"for loop at line "<< forloop->get_file_info()->get_line() <<endl;
std::vector< SgVarRefExp * > ref_vec;
collectVarRefs (forloop, ref_vec);
for (std::vector< SgVarRefExp * >::iterator iter = ref_vec.begin(); iter!= ref_vec.end(); iter ++)
{
SgSymbol* s = (*iter)->get_symbol();
omp_construct_enum atr = getDataSharingAttribute (*iter);
// will redirect to a .output file to enable diff-based correctness checking
cout<<s->get_name()<<"\t"<<toString(atr) <<endl;
}
}
}
}
int main(int argc, char * argv[])
{
SgProject *project = frontend (argc, argv);
visitorTraversal myvisitor;
myvisitor.traverseInputFiles(project,preorder);
return backend(project);
}
測試命令列
./getDataSharingAttribute -c -rose:openmp:ast_only openmpcode.c
AST 節點的反解析
[edit | edit source]它們定義在
src/backend/unparser/languageIndependenceSupport/unparseLanguageIndependentConstructs.h
src/backend/unparser/languageIndependenceSupport/unparseLanguageIndependentConstructs.C
從您的翻譯器啟用 OpenMP 處理
[edit | edit source]啟用 OpenMP 解析和 AST 建立
[edit | edit source]最簡單且推薦的方法是在您的翻譯器中傳遞命令列選項 "-rose:OpenMP:ast_only"。
- 這將開啟解析 OpenMP 指令和建立專用 OpenMP AST 節點的功能。使用者可以選擇開啟/關閉 OpenMP 解析功能。
第二個選項(推薦)是您可以在翻譯器中內部推送選項
// Option 2: recommended
#include "rose.h"
int main(int argc, char* argv[])
{
vector<string> argvList(argv,argv+argc);
if (your-condition-meet)
argvList.push_back("-rose:OpenMP:ast_only");
// the frontend will correctly handle OpenMP.
// All internal flags will be automatically set correctly.
// Several internal actions will be turned on in parsing, translation and the connection to the backend compiler
SgProject* project = frontend (argvList);
//...
}
第三個選項(不推薦),您可以複製翻譯器中的所有內部處理,如 https://github.com/rose-compiler/rose/blob/master/src/frontend/SageIII/sage_support/cmdline.cpp 和 https://github.com/rose-compiler/rose/blob/master/src/frontend/SageIII/sage_support/sage_support.cpp 所示
- 這有點複雜,因為您現在接觸到了專案和檔案級別的內部標誌。
- 您必須瞭解幾個標誌如何協同工作以控制解析、AST 建立和降級。
- 並明確呼叫 OpenMP 處理函式
- 如果需要後端編譯器,則將 "-DOPENMP" 傳遞給後端編譯器。
// Option 3: not really recommended due to the complexity involved.
#include "rose.h"
#include "ompAstConstruction.h"
int main(int argc, char* argv[])
{
vector<string> argvList(argv, argv+argc);
// the default frontend does not handle OpenMP at all.
SgProject* project = frontend (argvList);
..
// optional
// OmpSupport::enable_debugging = true;
// We assuming one single input file at a time
// You need to do this for all file if your translator accepts multiple files
SgFile * cur_file = project->get_fileList()[0];
// set three flags related to OpenMP processing
cur_file->set_openmp(true); // the top level flag
cur_file->set_openmp_parse_only(false);
cur_file->set_openmp_ast_only(true);
cur_file->set_openmp_lowering(false);
// process OpenMP directives within this file, based on the flag setting
// At least two phases are involved: one is to do the parsing and AST creation
// the other is to handle -DOPENMP when connecting to the backend compiler
OmpSupport::processOpenMP(isSgSourceFile(cur_file));
AstTests::runAllTests(project);
return backend(project);
}
啟用 OpenMP 降級
[edit | edit source]有時需要從您自己的翻譯器中呼叫 OpenMP 降級,而不是從 ROSE 的內建 frontend() 中呼叫。以下是一個示例
#include "rose.h"
#include "ompAstConstruction.h"
int main()
{
SgProject* project = frontend(argvList,frontendConstantFolding);
..
OmpSupport::enable_accelerator = true;
OmpSupport::enable_debugging = true;
// We only process one single input file at a time
ROSE_ASSERT (project->get_fileList().size() ==1);
SgFile * cur_file = project->get_fileList()[0];
// set three flags related to OpenMP processing
cur_file->set_openmp(true);
cur_file->set_openmp_lowering(true);
cur_file->set_openmp_parse_only(false);
// process OpenMP directives, including omp target
OmpSupport::processOpenMP(isSgSourceFile(cur_file));
AstTests::runAllTests(project);
return backend(project);
}
檢測支援
[edit | edit source]XOMP(ROSE 的 OpenMP 執行時層)支援簡單的事件檢測來收集關鍵 OpenMP 事件的時間戳。收集的資料有助於進一步分析,例如調查執行期間的序列與並行區域。
環境變數以開啟此支援
- XOMP_REGION_INSTR =0|1: 僅公開此環境變數將開啟此支援。預設情況下此選項處於關閉狀態,以避免不必要的開銷。
- 在 BASH 中:鍵入 "export XOMP_REGION_INSTR=1"
開啟此功能後,使用 rose 編譯您的 OpenMP 程式碼。可執行檔案將生成一個數據檔案,其檔名字首為時間戳,例如 "2013_03_05_10_05_45.jacobi"。此檔案將包含時間戳、值 1 或 2 以及序列和並行執行之間每次更改的檔案位置。
從 XOMP 生成的 data 檔案生成圖形的示例 GNU plot 指令碼
# cat timeline-plot.sc set xlabel 'time stamps' set yrange [0:3] #set output "lulesh.eps" #set terminal postscript eps plot "sp.A.8threads" using ($1-1362509569.298380):2 with lines #plot "timeline1.data" using 1:2 with lines
示例生成的 GNU plot 圖形:X 軸是時間軸,Y 軸用於序列(值 1)與並行(值 2)執行

,

此支援的相關提交
- https://github.com/rose-compiler/edg4x-rose/commit/59233fc54208fbb8ad78e24eb76266cec08ee55e,最新
- https://github.com/rose-compiler/edg4x-rose/commit/3f0a87daa6ac24b4cd22fadbef5b4a507317c6bf,
- https://github.com/rose-compiler/edg4x-rose/commit/ff1ab8601365d400f730ea5606f3b4f44316c72a,最早提交
2015 年 7 月 7 日收集的資料
直接原始碼行
[liao6@tux322:~/workspace/masterDevClean/sourcetree/src/frontend/SageIII]wc omp*
1900 6723 75176 ompAstConstruction.cpp
20 39 504 ompAstConstruction.h
1504 4821 45545 ompFortranParser.C
128 365 3361 omp.h
241 1171 9011 omplexer.ll
284 779 9714 omp_lib.f90
57 119 1784 omp_lib.h
17 76 647 omp_lib_kinds.h
1056 3010 40607 ompparser.yy
5207 17103 186349 total
[liao6@tux322:~/workspace/masterDevClean/sourcetree/src/midend/programTransformation/ompLowering]wc *.h *.inc *.cu *.cpp *.sh *.c
152 702 7533 libgomp_g.h
51 208 1814 libompc.h
57 130 1885 libxompf.h
387 2424 17562 libxomp.h
212 1232 10559 omp_lowering.h
771 2841 38153 run_me_callers2.inc
771 2841 35845 run_me_callers.inc
67843 103833 1891978 run_me_defs.inc
76291 143257 1761968 run_me_task_defs.inc
973 4246 35237 xomp_cuda_lib.cu
334 1921 13137 xomp_cuda_lib_inlined.cu
5939 26563 267555 omp_lowering.cpp
24 139 1021 run_me_caller_generator2.sh
21 101 736 run_me_caller_generator.sh
45 163 1138 run_me_generator.sh
86 405 2709 run_me_task_generator.sh
156 584 4418 xomp_accelerator_sched_test.c
194 821 5919 xomp_accelerator_sched_test_v2.c
1823 6642 54788 xomp.c
156130 299053 4153955 total
間接支援原始檔
[liao6@tux322:~/workspace/masterDevClean/sourcetree/src/midend/programTransformation/astOutlining]wc *.cc *.cc
576 1390 15514 ASTtools.cc
175 539 4869 Block.cc
307 668 6188 Case.cc
371 1254 10678 Check.cc
97 537 3803 CollectVars.cc
33 79 682 Copy.cc
101 263 2611 ExtractIfs.cc
219 1009 9306 GenerateCall.cc
1422 6803 61202 GenerateFunc.cc
185 482 3563 If.cc
63 131 1524 IfDirectiveContextFinder.cc
163 481 4711 IfDirectiveExtractor.cc
785 3165 33825 Insert.cc
149 484 4329 Jumps.cc
59 120 945 NameGenerator.cc
292 910 9030 NonLocalControlFlow.cc
64 176 1895 NonLocalDecls.cc
373 1299 12924 Outliner.cc
405 1416 12345 PragmaInterface.cc
41 94 1191 PrePostTraversal.cc
102 357 3178 Preprocess.cc
445 1373 14757 PreprocessingInfo.cc
436 1352 12210 PreprocIfs.cc
209 763 7185 StmtRewrite.cc
33 85 893 This.cc
293 1045 10043 ThisExprs.cc
712 3499 33690 Transform.cc
424 1405 13887 VarSym.cc
576 1390 15514 ASTtools.cc
175 539 4869 Block.cc
307 668 6188 Case.cc
371 1254 10678 Check.cc
97 537 3803 CollectVars.cc
33 79 682 Copy.cc
101 263 2611 ExtractIfs.cc
219 1009 9306 GenerateCall.cc
1422 6803 61202 GenerateFunc.cc
185 482 3563 If.cc
63 131 1524 IfDirectiveContextFinder.cc
163 481 4711 IfDirectiveExtractor.cc
785 3165 33825 Insert.cc
149 484 4329 Jumps.cc
59 120 945 NameGenerator.cc
292 910 9030 NonLocalControlFlow.cc
64 176 1895 NonLocalDecls.cc
373 1299 12924 Outliner.cc
405 1416 12345 PragmaInterface.cc
41 94 1191 PrePostTraversal.cc
102 357 3178 Preprocess.cc
445 1373 14757 PreprocessingInfo.cc
436 1352 12210 PreprocIfs.cc
209 763 7185 StmtRewrite.cc
33 85 893 This.cc
293 1045 10043 ThisExprs.cc
712 3499 33690 Transform.cc
424 1405 13887 VarSym.cc
17068 62358 593956 total
[liao6@tux322:~/workspace/masterDevClean/sourcetree/src/frontend/SageIII/sageInterface]wc sageBuilder.C sageBuilder.h sageBuilder_fortran.C sageInterface.C sageInterface.h sageInterface_type.C
16842 64856 784120 sageBuilder.C
1489 8428 90956 sageBuilder.h
104 212 3408 sageBuilder_fortran.C
19213 71263 847054 sageInterface.C
2406 14864 128891 sageInterface.h
2208 7633 87896 sageInterface_type.C
42262 167256 1942325 total
ROSE 中的 OpenMP 實現支援 OpenMP 3.0 和 OpenMP 4.0 中的加速器(GPU)支援。它有三個組成部分:前端、中間端和執行時層,分別有 4849、6151 和 6203 行程式碼。總共有 17203 行程式碼專門用於實現 OpenMP。
此外,ROSE 中還有另外兩個支援元件用於幫助 OpenMP 實現:1) AST 概述器(將程式碼部分提取到函式中)和 2) AST 介面函式(構建和操作 AST)。AST 概述器有 17068 行程式碼。AST 介面函式有 42262 行程式碼。因此,間接原始檔的行數為 42262 行。
計算直接和間接原始檔,ROSE 中與 OpenMP 實現相關的程式碼行數為 76533 行。
使用線上軟體構建成本計算器 (http://www.csgnetwork.com/costconstrmodelcalc.html),假設開發人員每月可以編寫和維護 500 行程式碼。我們估計開發 17.2K 行專門的 OpenMP 原始檔需要 48 個工作月(或使用 10K 每人每月成本率為 480K)。直接和間接原始檔的總成本估計為 228 個工作月或 228 萬。
我們還沒有嘗試將 ROSE 中的解析和反解析元件新增到此估計中。粗略估計解析輸入程式碼和之後反解析原始碼為輸出需要大約 100 萬行程式碼。
- Chunhua Liao、Yonghong Yan、Bronis R. de Supinski、Daniel J. Quinlan 和 Barbara Chapman,“OpenMP 加速器模型的早期經驗”。在低功耗裝置和加速器時代的 OpenMP 中,第 84-98 頁。施普林格柏林海德堡,2013 年。
- Chunhua Liao、Daniel J. Quinlan、Thomas Panas 和 Bronis de Supinski,基於 ROSE 的 OpenMP 3.0 研究編譯器,支援多個執行時庫,第六屆 OpenMP 國際研討會 (IWOMP),2010 年 6 月 14-16 日,日本筑波。LLNL-CONF-422873