Skip to content

Commit

Permalink
Remove OmpAttribute leftover
Browse files Browse the repository at this point in the history
  • Loading branch information
ouankou committed Dec 14, 2022
1 parent 71be1f1 commit 973614c
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 121 deletions.
5 changes: 2 additions & 3 deletions src/ROSETTA/src/support.C
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "ROSETTA_macros.h"
#include "AstNodeClass.h"
//#include "OmpAttribute.h"

// What should be the behavior of the default constructor for Grammar

Expand Down Expand Up @@ -1067,10 +1066,10 @@ Grammar::setUpSupport ()
// Liao, 10/28/2008: Support for OpenMP 3.0 model for C/C++ pragma, will use it for Fortran later on, changed fortran_openmp to openmp
File.setDataPrototype ( "bool", "openmp", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_FLAG_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// Liao, 5/31/2009: Only invoke the OpenMP C/C++ and Fortran directive parsers and generate OmpAttributes
// Liao, 5/31/2009: Only invoke the OpenMP C/C++ and Fortran directive parsers from OpenMPIR
File.setDataPrototype ( "bool", "openmp_parse_only", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_FLAG_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// Only generate SgOmp* nodes from OmpAttributes in AST, no further actions
// Only generate SgOmp* nodes from OpenMPIR in AST, no further actions
File.setDataPrototype ( "bool", "openmp_ast_only", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_FLAG_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// Lowering OpenMP directives to code with explicit runtime calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4047,8 +4047,17 @@ FortranCodeGeneration_locatedNode::unparsePragmaDeclStmt (SgStatement* stmt, SgU
ASSERT_not_null(pragma);

string txt = pragma->get_pragma();
// Check the leading keyword
// FIXME: Followed code to remove OmpAttribute leftover should be correct, but it will cause Fortran OpenMP tests fail.
// There may be a bug in the OpenMP AST constructor for Fortran.
/*
istringstream istr(txt);
std::string key;
istr >> key;
if (key == "omp")
*/
// Followed code is incorrect, but it happens to make Fortran OpenMP tests pass.
AstAttribute* att = stmt->getAttribute("OmpAttributeList"); //TODO: we removed OmpAttribute and this need to be changed
//ASSERT_not_null(NULL);
if (att)
curprint("!$");
else
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/CxxFrontend/EDG
Submodule EDG updated from 4b86ae to 03ec5e
70 changes: 4 additions & 66 deletions src/frontend/SageIII/ompAstConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,68 +1410,6 @@ namespace OmpSupport
return result;
}

//! Build a map clause with a given operation type from OmpAttribute
// map may have several variants: tofrom, to, from, and alloc.
// the variables for each may have dimension info
/*SgOmpMapClause* buildOmpMapClause(OmpAttribute* att, omp_construct_enum map_op)
{
ROSE_ASSERT(att !=NULL);
ROSE_ASSERT (att->isMapVariant(map_op));
if (!att->hasMapVariant(map_op))
return NULL;
SgOmpClause::omp_map_operator_enum sg_op = toSgOmpClauseMapOperator(map_op);
SgExprListExp* explist=buildExprListExp();
SgOmpMapClause* result = new SgOmpMapClause(explist, sg_op);
ROSE_ASSERT(result != NULL);
setOneSourcePositionForTransformation(result);
explist->set_parent(result);
// build variable list
setClauseVariableList(result, att, map_op);
//this is somewhat inefficient.
// since the attribute has dimension info for all map clauses
//But we don't want to move the dimension info to directive level
result->set_array_dimensions(att->array_dimensions);
//A translation from OmpSupport::omp_construct_enum to SgOmpClause::omp_map_dist_data_enum is needed here.
std::map<SgSymbol*, std::vector<std::pair<OmpSupport::omp_construct_enum, SgExpression*> > > attDistMap = att->dist_data_policies;
std::map<SgSymbol*, std::vector<std::pair<OmpSupport::omp_construct_enum, SgExpression*> > >::iterator iter;
std::map<SgSymbol*, std::vector<std::pair<SgOmpClause::omp_map_dist_data_enum, SgExpression*> > > convertedDistMap;
for (iter= attDistMap.begin(); iter!=attDistMap.end(); iter++)
{
SgSymbol* s = (*iter).first;
std::vector<std::pair<OmpSupport::omp_construct_enum, SgExpression*> > src_vec = (*iter).second;
std::vector<std::pair<OmpSupport::omp_construct_enum, SgExpression*> >::iterator iter2;
std::vector<std::pair<SgOmpClause::omp_map_dist_data_enum, SgExpression*> > converted_vec;
for (iter2=src_vec.begin(); iter2!=src_vec.end(); iter2 ++ )
{
std::pair<OmpSupport::omp_construct_enum, SgExpression*> src_pair = *iter2;
if (src_pair.first == OmpSupport::e_duplicate)
{
converted_vec.push_back(make_pair(SgOmpClause::e_omp_map_dist_data_duplicate, src_pair.second) );
} else
if (src_pair.first == OmpSupport::e_cyclic)
{
converted_vec.push_back(make_pair(SgOmpClause::e_omp_map_dist_data_cyclic, src_pair.second) );
} else
if (src_pair.first == OmpSupport::e_block)
{
converted_vec.push_back(make_pair(SgOmpClause::e_omp_map_dist_data_block, src_pair.second) );
} else
{
cerr<<"error. buildOmpMapClause() :unrecognized source dist data policy enum:"<<src_pair.first <<endl;
ROSE_ASSERT (false);
} // end for iter2
} // end for iter
convertedDistMap[s]= converted_vec;
}
result->set_dist_data_policies(convertedDistMap);
return result;
}*/

//! Convert omp_pragma_list to SgOmpxxx nodes
void OpenMPIRToSageAST(SgSourceFile *sageFilePtr)
{
Expand Down Expand Up @@ -1594,7 +1532,7 @@ namespace OmpSupport
// after converting Fortran comments to Pragmas.
// x. We should not tweak the original text for the pragmas.
// x. We should not remove the end pragma declaration since SgBasicBlock is not unparsed.
// In the end , the pragmas don't matter too much, the OmpAttributes attached to them
// In the end , the pragmas don't matter too much, the OpenMPIR attached to them
// are used to guide translations.
removeStatement(end_decl);
// we should save those useless end pragmas to a list
Expand Down Expand Up @@ -1643,13 +1581,13 @@ namespace OmpSupport

//! Convert OpenMP Fortran comments to pragmas
// main purpose is to
// x. Generate pragmas from OmpAttributes and insert them into the right places
// x. Generate pragmas from OpenMPIR and insert them into the right places
// since the floating comments are very difficult to work with
// we move them to the fake pragmas to ease later translations.
// The backend has been extended to unparse the pragma in order to debug this step.
// x. Enclose affected Fortran statement into a basic block
// x. Merge clauses from END directives to the begin directive
// This will temporarily introduce C/C++-like AST with pragmas attaching OmpAttributes.
// This will temporarily introduce C/C++-like AST with pragmas.
// This should be fine since we have SgBasicBlock in Fortran AST also.
//
// The benefit is that pragma-to-AST conversion written for C/C++ can
Expand All @@ -1660,7 +1598,7 @@ namespace OmpSupport
// We reuse the pragma list for C/C++ here
//ROSE_ASSERT (omp_pragma_list.size() ==0);
ROSE_ASSERT (sageFilePtr != NULL);
// step 1: Each OmpAttribute will have a dedicated SgPragmaDeclaration for it
// step 1: Each OpenMPIR will have a dedicated SgPragmaDeclaration for it
std::vector<std::tuple<SgLocatedNode*, PreprocessingInfo*, OpenMPDirective*>>::iterator iter;
for (iter = fortran_omp_pragma_list.begin(); iter != fortran_omp_pragma_list.end(); iter++)
{
Expand Down
6 changes: 1 addition & 5 deletions src/frontend/SageIII/ompSupport.C
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Refined OmpAttribute connected to a parser using Bison
//Liao, 9/18/2008
//

// tps (01/14/2010) : Switching from rose.h to sage3.
#include "sage3basic.h"
#include "sageBuilder.h"
Expand Down Expand Up @@ -70,7 +66,7 @@ namespace OmpSupport
case e_end_parallel_do:result = "end parallel do"; break;
case e_end_parallel_sections:result = "end parallel sections"; break;
case e_end_parallel_workshare:result = "end parallel workshare"; break;
case e_end_parallel:result = "end parallel"; break;
case e_end_parallel:result = "end parallel_support"; break;
case e_end_sections:result = "end sections"; break;
case e_end_single:result = "end single"; break;
case e_end_task:result = "end task"; break;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/SageIII/omp_exprparser_parser.yy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* OpenMP C and C++ Grammar */
/* Author: Markus Schordan, 2003 */
/* Modified by Christian Biesinger 2006 for OpenMP 2.0 */
/* Modified by Chunhua Liao for OpenMP 3.0 and connect to OmpAttribute, 2008 */
/* Modified by Chunhua Liao for OpenMP 3.0, 2008 */
/* Updated by Chunhua Liao for OpenMP 4.5, 2017 */

/*
Expand Down
1 change: 0 additions & 1 deletion src/frontend/SageIII/sageInterface/sageInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -22294,7 +22294,6 @@ static bool isSingleAppearanceReduction(SgVarRefExp* ref1, OmpSupport::omp_const
//!Recognize and collect reduction variables and operations within a C/C++ loop, following OpenMP 3.0 specification for allowed reduction variable types and operation types.
/* This code is refactored from project/autoParallelization/autoParSupport.C
std::vector<SgInitializedName*>
RecognizeReduction(SgNode *loop, OmpSupport::OmpAttribute* attribute, std::vector<SgInitializedName*>& candidateVars/)
* Algorithms:
* for each scalar candidate which are both live-in and live-out for the loop body
* (We don't use liveness analysis here for simplicity)
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/SageIII/sage_support/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2250,9 +2250,9 @@ SgFile::usage ( int status )
" -rose:OpenMP, -rose:openmp\n"
" follow OpenMP 3.0 specification for C/C++ and Fortran, perform one of the following actions:\n"
" -rose:OpenMP:parse_only, -rose:openmp:parse_only\n"
" parse OpenMP directives to OmpAttributes, no further actions (default behavior now)\n"
" parse OpenMP directives to OpenMPIR, no further actions (default behavior now)\n"
" -rose:OpenMP:ast_only, -rose:openmp:ast_only\n"
" on top of -rose:openmp:parse_only, build OpenMP AST nodes from OmpAttributes, no further actions\n"
" on top of -rose:openmp:parse_only, build OpenMP AST nodes from OpenMPIR, no further actions\n"
" -rose:OpenMP:lowering, -rose:openmp:lowering\n"
" on top of -rose:openmp:ast_only, transform AST with OpenMP nodes into multithreaded code \n"
" targeting GCC GOMP runtime library\n"
Expand Down
6 changes: 0 additions & 6 deletions src/midend/astDiagnostics/AstConsistencyTests.C
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,6 @@ AstTests::runAllTests(SgProject* sageProject)
// This is because when building AST bottom-up, some temporary symbol may be generated to be referenced
// by those variable references generated just using names. When all variable references are fixed,
// those symbols are not used any more and then should be removed from memory pool.
//
// Liao 1/24/2013: I have to comment this out
// for #define N 1000, when N is used in OpenMP directives, the OmpSupport::attachOmpAttributeInfo() will try to generate a
// variable reference to N, But N cannot be found in AST, so unknownType is used. But symbols with unknowntype will be removed
// by this clearUnusedVariableSymbols()
//SageInterface::clearUnusedVariableSymbols();

// printf ("Inside of AstTests::runAllTests(sageProject = %p) \n",sageProject);

Expand Down
32 changes: 0 additions & 32 deletions tests/nonsmoke/functional/CompileTests/OpenMP_tests/parseOmp.C
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,6 @@ Last Modified: 9/19/2008
using namespace std;
using namespace OmpSupport;

#if 0
class visitorTraversal : public AstSimpleProcessing
{
protected:
virtual void visit(SgNode* n);
};

void visitorTraversal::visit(SgNode* node)
{
// Some OmpAttribute may be attached redundantly,
// e.g., omp for is attached to both the pragma and the loop.
OmpAttributeList* attributelist = getOmpAttributeList(node);
if (attributelist)
{
// cout<<"Found att attached to "<<node<<" "<<node->class_name()<<" at line "
// <<node->get_file_info()->get_line()<<endl;
// attributelist->print();//debug only for now
}
// Show OpenMP nodes also for -rose:openmp:ast_only
if (SageInterface::isOmpStatement(node))
{
cout<<"----------------------------"<<endl;
cout<<"Found a SgOmp Statement:"<<node->class_name()<<"@"<<node<<endl;
// cout<<isSgStatement(node)->unparseToString()<<endl;;
cout<<"file info: @"<< isSgStatement(node)->get_file_info() <<":"<<isSgStatement(node)->get_file_info()->get_filename();
cout<<":"<<isSgStatement(node)->get_file_info()->get_line()<<endl;
// We now enforce OmpStatement nodes to have real file info objecs.
ROSE_ASSERT(isSgStatement(node)->get_file_info()->isTransformation()==false);
}
}
#endif

int main(int argc, char * argv[])
{
SgProject *project = frontend (argc, argv);
Expand Down
3 changes: 0 additions & 3 deletions tests/nonsmoke/unit/SageInterface/collectFunctionSideEffect.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

#include "CommandOptions.h"

//OpenMP attribute for OpenMP 3.0
#include "OmpAttribute.h"

//Array Annotation headers
#include <CPPAstInterface.h>
#include <ArrayAnnot.h>
Expand Down

0 comments on commit 973614c

Please sign in to comment.