Skip to content

Commit

Permalink
Merge pull request #82 from passlab/xinyao
Browse files Browse the repository at this point in the history
Fixed issue #68
  • Loading branch information
ouankou authored Nov 7, 2019
2 parents f51da63 + fd10667 commit 9bb30f3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
63 changes: 48 additions & 15 deletions src/OpenMPIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3708,10 +3708,9 @@ OpenMPClause* OpenMPLinearClause::addLinearClause(OpenMPDirective *directive, Op
current_clauses->push_back(new_clause);
(*all_clauses)[OMPC_linear] = current_clauses;
}
else {
//std::cerr << "Cannot have two bind clause for the directive " << directive->getKind() << ", ignored\n";
else {
new_clause = new OpenMPLinearClause(modifier);
current_clauses->push_back(new_clause);
current_clauses->push_back(new_clause);
};
(*all_clauses)[OMPC_linear] = current_clauses;
return new_clause;
Expand All @@ -3723,8 +3722,6 @@ void OpenMPLinearClause::mergeLinear(OpenMPDirective *directive, OpenMPClause* c
std::vector<OpenMPClause*>* current_clauses = directive->getClauses(OMPC_linear);
OpenMPClause* new_clause = NULL;

current_clauses = directive->getClauses(OMPC_linear);

for (std::vector<OpenMPClause*>::iterator it = current_clauses->begin(); it != current_clauses->end()-1; it++) {

if (((OpenMPLinearClause*)(*it))->getModifier() == ((OpenMPLinearClause*)current_clause)->getModifier() && ((OpenMPLinearClause*)(*it))->getUserDefinedStep() == ((OpenMPLinearClause*)current_clause)->getUserDefinedStep()) {
Expand Down Expand Up @@ -3861,7 +3858,6 @@ OpenMPClause* OpenMPAffinityClause::addAffinityClause(OpenMPDirective *directive
return new_clause;
}

//OpenMPClause* OpenMPDependClause::addDependClause(OpenMPDirective *directive, OpenMPDependClauseModifier modifier, OpenMPDependClauseType type, std::vector<std::vector<const char*>* > depend_iterators_definition_class) {
OpenMPClause* OpenMPDependClause::addDependClause(OpenMPDirective *directive, OpenMPDependClauseModifier modifier, OpenMPDependClauseType type) {

std::map<OpenMPClauseKind, std::vector<OpenMPClause*>* >* all_clauses = directive->getAllClauses();
Expand All @@ -3875,21 +3871,58 @@ OpenMPClause* OpenMPDependClause::addDependClause(OpenMPDirective *directive, Op
current_clauses->push_back(new_clause);
(*all_clauses)[OMPC_depend] = current_clauses;
} else {
for(std::vector<OpenMPClause*>::iterator it = current_clauses->begin(); it != current_clauses->end(); ++it) {
if (((OpenMPDependClause*)(*it))->getModifier() == modifier &&
((OpenMPDependClause*)(*it))->getType() == type) {
new_clause = (*it);
return new_clause;
}
}
/* could fine the matching object for this clause */
//new_clause = new OpenMPDependClause(modifier, type, depend_iterators_definition_class);
new_clause = new OpenMPDependClause(modifier, type);
current_clauses->push_back(new_clause);
}
(*all_clauses)[OMPC_depend] = current_clauses;
return new_clause;
}

void OpenMPDependClause::mergeDepend(OpenMPDirective *directive, OpenMPClause* current_clause) {
std::map<OpenMPClauseKind, std::vector<OpenMPClause*>* >* all_clauses = directive->getAllClauses();
std::vector<OpenMPClause*>* current_clauses = directive->getClauses(OMPC_depend);
OpenMPClause* new_clause = NULL;

if (current_clauses->size() == true) return;

for (std::vector<OpenMPClause*>::iterator it = current_clauses->begin(); it != current_clauses->end()-1; it++) {
if (((OpenMPDependClause*)(*it))->getModifier() == ((OpenMPDependClause*)current_clause)->getModifier() && ((OpenMPDependClause*)(*it))->getType() == ((OpenMPDependClause*)current_clause)->getType()) {
bool normalize = true;
std::vector<vector<const char*>* >* depend_iterators_definition_previous = ((OpenMPDependClause*)(*it))->getDependIteratorsDefinitionClass();
std::vector<vector<const char*>* >* depend_iterators_definition_current = ((OpenMPDependClause*)current_clause)->getDependIteratorsDefinitionClass();
if (depend_iterators_definition_previous->size() == depend_iterators_definition_current->size()){
for (std::vector<vector<const char*>* >::iterator it_expr_current_outer = depend_iterators_definition_current->begin(); it_expr_current_outer != depend_iterators_definition_current->end(); it_expr_current_outer++) {
for (std::vector<vector<const char*>* >::iterator it_expr_previous_outer = depend_iterators_definition_previous->begin(); it_expr_previous_outer != depend_iterators_definition_previous->end(); it_expr_previous_outer++) {
bool merge = false;
if (strcmp((*it_expr_current_outer)->at(0), (*it_expr_previous_outer)->at(0)) == 0 && strcmp((*it_expr_current_outer)->at(1), (*it_expr_previous_outer)->at(1)) == 0 && strcmp((*it_expr_current_outer)->at(2), (*it_expr_previous_outer)->at(2)) == 0 && strcmp((*it_expr_current_outer)->at(3), (*it_expr_previous_outer)->at(3)) == 0 && strcmp((*it_expr_current_outer)->at(4), (*it_expr_previous_outer)->at(4)) == 0){
bool merge = true;
break;
}
if (it_expr_previous_outer == depend_iterators_definition_previous->end()-1 && merge == false) {
normalize = false;
}
}
if (normalize == false) break;
}
if (normalize == true) {
std::vector<const char *>* expressions_previous = ((OpenMPDependClause*)(*it))->getExpressions();
std::vector<const char *>* expressions_current = current_clause->getExpressions();
for (std::vector<const char *>::iterator it_expr_current = expressions_current->begin(); it_expr_current != expressions_current->end(); it_expr_current++) {
bool para_merge = true;
for (std::vector<const char *>::iterator it_expr_previous = expressions_previous->begin(); it_expr_previous != expressions_previous->end(); it_expr_previous++) {
if (strcmp(*it_expr_current, *it_expr_previous) == 0 ){
para_merge = false;
}
}
if (para_merge == true) expressions_previous->push_back(*it_expr_current);
}
current_clauses->pop_back();
break;
}
}
}
}
}
OpenMPClause* OpenMPDepobjUpdateClause::addDepobjUpdateClause(OpenMPDirective *directive, OpenMPDepobjUpdateClauseDependeceType type) {

std::map<OpenMPClauseKind, std::vector<OpenMPClause*>* >* all_clauses = directive->getAllClauses();
Expand Down
1 change: 1 addition & 0 deletions src/OpenMPIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ class OpenMPDependClause : public OpenMPClause {
static OpenMPClause * addDependClause(OpenMPDirective *, OpenMPDependClauseModifier, OpenMPDependClauseType);
std::string toString();
void generateDOT(std::ofstream&, int, int, std::string);
void mergeDepend(OpenMPDirective*, OpenMPClause*);

};

Expand Down
2 changes: 1 addition & 1 deletion src/ompparser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ depend_with_modifier_clause : DEPEND { firstParameter = OMPC_DEPEND_MODIFIER_uns
;

depend_parameter : dependence_type ':' var_list
| depend_modifier ',' dependence_type ':' var_list
| depend_modifier ',' dependence_type ':' var_list { ((OpenMPDependClause*)current_clause)->mergeDepend(current_directive, current_clause); }
;
dependence_type : depend_enum_type { ((OpenMPDependClause*)current_clause)->setDependIteratorsDefinitionClass(depend_iterators_definition_class); }
;
Expand Down
12 changes: 12 additions & 0 deletions tests/task.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@ PASS: #pragma omp task affinity (iterator ( int bba=4:120:2, double b=1:220:3, i

#pragma omp task affinity(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9):b, c) in_reduction (test_identifier : x11, y, z) untied mergeable priority(5) detach(abc) depend(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9),in:m, n) private (a[foo(x, goo(x, y)):100], b[1:30], c) firstprivate (foo(x), y) shared (a, b, c[1:10])
PASS: #pragma omp task private (a[foo(x,goo(x,y)):100], b[1:30], c) firstprivate (foo(x), y) shared (a, b, c[1:10]) untied mergeable in_reduction (test_identifier : x11, y, z) depend (iterator ( int bba=4:120:2, b=1:220:3, int c=2:57:9 ), in : m, n) priority (5) affinity (iterator ( int bba=4:120:2, b=1:220:3, int c=2:57:9 ) : b, c) detach (abc)

#pragma omp task depend(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9),in:m, n) depend(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9),in:m, n, o, p)
PASS: #pragma omp task depend (iterator ( int bba=4:120:2, b=1:220:3, int c=2:57:9 ), in : m, n, o, p)

#pragma omp task depend(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9),in:m, n) depend(iterator(int bba=4:120:2),in:m, n)
PASS: #pragma omp task depend (iterator ( int bba=4:120:2, b=1:220:3, int c=2:57:9 ), in : m, n) depend (iterator ( int bba=4:120:2 ), in : m, n)

#pragma omp task depend(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9),in:m, n) depend(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9),inout:m, n)
PASS: #pragma omp task depend (iterator ( int bba=4:120:2, b=1:220:3, int c=2:57:9 ), in : m, n) depend (iterator ( int bba=4:120:2, b=1:220:3, int c=2:57:9 ), inout : m, n)

#pragma omp task depend(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9),inout:m, n) depend(iterator(int bba=4:120:2, b=1:220:3, int c=2:57:9),inout:m, n, o, p)
PASS: #pragma omp task depend (iterator ( int bba=4:120:2, b=1:220:3, int c=2:57:9 ), inout : m, n, o, p)

0 comments on commit 9bb30f3

Please sign in to comment.