Skip to content

Commit

Permalink
address internal issue llvm#49
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Kosmynin committed Nov 13, 2019
1 parent a3d8f99 commit 85a4ef8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
10 changes: 6 additions & 4 deletions clang/tools/nec-aurora-build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ find_program(NECAURORA_TARGET_COMPILER
"/opt/nec/ve/bin/"
ENV PATH)

if(NOT NECAURORA_TARGET_COMPILER)
message(STATUS "NEC target compiler could not be found, defaulting to GCC.")
# Use a separate variable to print this message every time.
find_program(NECAURORA_TARGET_COMPILER_GCC gcc)
# if ncc was not found and gcc is not set stop
if(NOT NECAURORA_TARGET_COMPILER AND NOT NECAURORA_TARGET_COMPILER_GCC)
message(FATAL_ERROR "NEC target compiler not found and GCC not set, exiting.")
# if ncc was not found vut gcc is set, use gcc
elseif(NOT NECAURORA_TARGET_COMPILER)
message(STATUS "NEC target compiler not found but GCC is set, using GCC.")
set(NECAURORA_TARGET_COMPILER "${NECAURORA_TARGET_COMPILER_GCC}")
endif()

Expand Down
4 changes: 2 additions & 2 deletions clang/tools/sotoc/src/Visitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ class CollectOMPClauseParamsVarsVisitor

class CollectOMPClauseParamsVisitor
: public clang::RecursiveASTVisitor<CollectOMPClauseParamsVisitor> {

CollectOMPClauseParamsVarsVisitor VarsVisitor;
bool InExplicitCast;
public:
CollectOMPClauseParamsVisitor(std::shared_ptr<TargetCodeRegion> &TCR)
: VarsVisitor(TCR), InExplicitCast(false) {};
bool VisitStmt(clang::Stmt *S) {
// THis relies on the captured statement being the last child
// This relies on the captured statement being the last child
if (llvm::isa<clang::CapturedStmt>(S)) {
return false;
}
Expand Down
25 changes: 25 additions & 0 deletions clang/tools/sotoc/test/arrays/dynamic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %sotoc-transform-compile
// RUN: %run-on-host | %filecheck %s

#include <stdio.h>
#include <stdlib.h>

int main() {
int* array = malloc(1000*sizeof(int));
int sum = 0;

#pragma omp target parallel for map(tofrom: array[0:1000])
for (int i = 0; i < 1000; i++) {
array[i] = 1;
}

for (int i = 0; i < 1000; i++) {
sum += array[i];
}

printf("%d", sum);

return 0;
}

// CHECK: 1000
16 changes: 16 additions & 0 deletions clang/tools/sotoc/test/arrays/dynamic_on_device.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %sotoc-transform-compile

#include <stdio.h>
#include <stdlib.h>
#include <omp.h>

int main() {
int* array = omp_target_alloc(1000*sizeof(int),0);

#pragma omp target parallel for is_device_ptr(array)
for (int i = 0; i < 1000; i++) {
array[i] = 1;
printf("SUCCESS: %x\n",&array);
}
return 0;
}

0 comments on commit 85a4ef8

Please sign in to comment.