diff --git a/aomp-device-libs/aompextras/src/cprint.c b/aomp-device-libs/aompextras/src/cprint.c new file mode 100644 index 0000000..1caba95 --- /dev/null +++ b/aomp-device-libs/aompextras/src/cprint.c @@ -0,0 +1,25 @@ +// compile with +// /home/rlieberm/rocm/aomp_13.0-2/bin/clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 -c cprint.c -emit-llvm -o cprint.bc -save-temps + +// dump the ll +// cp cprint-openmp-amdgcn-amd-amdhsa-gfx906.tmp.ll ~/git/aomp12/aomp-extras/aomp-device-libs/aompextras/src/cprint.ll + + +#include +#pragma omp declare target +void f90print_(char *s) { + printf("%s\n", s); +} +void f90printi_(char *s, int *i) { + printf("%s %d\n", s, *i); +} +void f90printl_(char *s, long *i) { + printf("%s %ld\n", s, *i); +} +void f90printf_(char *s, float *f) { + printf("%s %f\n", s, *f); +} +void f90printd_(char *s, double *d) { + printf("%s %g\n", s, *d); +} +#pragma omp end declare target diff --git a/aomp-device-libs/aompextras/src/cprint.ll b/aomp-device-libs/aompextras/src/cprint.ll new file mode 100644 index 0000000..a0c425a --- /dev/null +++ b/aomp-device-libs/aompextras/src/cprint.ll @@ -0,0 +1,277 @@ +; ModuleID = 'cprint-openmp-amdgcn-amd-amdhsa-gfx906.tmp.bc' +source_filename = "cprint.c" +target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7" +target triple = "amdgcn-amd-amdhsa" + +@.str.1 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %d\0A\00", align 1 +@.str.3 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %f\0A\00", align 1 +@.str.4 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %g\0A\00", align 1 + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90print_(i8* %s) local_unnamed_addr #0 { +entry: + %0 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %0, 28 + %1 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %2 = bitcast i8* %1 to i32* + %3 = addrspacecast i32* %2 to i32 addrspace(1)* + store i32 24, i32 addrspace(1)* %3, align 4 + %4 = getelementptr inbounds i8, i8* %1, i64 4 + %5 = bitcast i8* %4 to i32* + %6 = addrspacecast i32* %5 to i32 addrspace(1)* + store i32 2, i32 addrspace(1)* %6, align 4 + %7 = getelementptr inbounds i8, i8* %1, i64 8 + %8 = bitcast i8* %7 to i32* + %9 = addrspacecast i32* %8 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %9, align 4 + %10 = getelementptr inbounds i8, i8* %1, i64 12 + %11 = bitcast i8* %10 to i32* + %12 = addrspacecast i32* %11 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %12, align 4 + %13 = getelementptr inbounds i8, i8* %1, i64 16 + %14 = bitcast i8* %13 to i32* + %15 = addrspacecast i32* %14 to i32 addrspace(1)* + store i32 4, i32 addrspace(1)* %15, align 4 + %16 = getelementptr inbounds i8, i8* %1, i64 20 + %17 = bitcast i8* %16 to i32* + %18 = addrspacecast i32* %17 to i32 addrspace(1)* + store i32 %0, i32 addrspace(1)* %18, align 4 + %19 = getelementptr inbounds i8, i8* %1, i64 24 + %20 = bitcast i8* %19 to i32* + %21 = addrspacecast i32* %20 to i32 addrspace(1)* + store i32 684837, i32 addrspace(1)* %21, align 1 + %22 = getelementptr inbounds i8, i8* %1, i64 28 + %23 = addrspacecast i8* %22 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %23, i8* align 1 %s, i32 %0, i1 false) + %24 = tail call i32 @printf_execute(i8* %1, i32 %total_buffer_size) #2 + ret void +} + +declare i32 @__strlen_max(i8*, i32) local_unnamed_addr + +declare i8* @printf_allocate(i32) local_unnamed_addr + +; Function Attrs: argmemonly nofree nosync nounwind willreturn +declare void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +declare i32 @printf_execute(i8*, i32) local_unnamed_addr + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90printi_(i8* %s, i32* nocapture readonly %i) local_unnamed_addr #0 { +entry: + %0 = load i32, i32* %i, align 4, !tbaa !4 + %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %1, 39 + %2 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %3 = bitcast i8* %2 to i32* + %4 = addrspacecast i32* %3 to i32 addrspace(1)* + store i32 32, i32 addrspace(1)* %4, align 4 + %5 = getelementptr inbounds i8, i8* %2, i64 4 + %6 = bitcast i8* %5 to i32* + %7 = addrspacecast i32* %6 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %7, align 4 + %8 = getelementptr inbounds i8, i8* %2, i64 8 + %9 = bitcast i8* %8 to i32* + %10 = addrspacecast i32* %9 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %10, align 4 + %11 = getelementptr inbounds i8, i8* %2, i64 12 + %12 = bitcast i8* %11 to i32* + %13 = addrspacecast i32* %12 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %13, align 4 + %14 = getelementptr inbounds i8, i8* %2, i64 16 + %15 = bitcast i8* %14 to i32* + %16 = addrspacecast i32* %15 to i32 addrspace(1)* + store i32 852000, i32 addrspace(1)* %16, align 4 + %17 = getelementptr inbounds i8, i8* %2, i64 20 + %18 = bitcast i8* %17 to i32* + %19 = addrspacecast i32* %18 to i32 addrspace(1)* + store i32 7, i32 addrspace(1)* %19, align 4 + %20 = getelementptr inbounds i8, i8* %2, i64 24 + %21 = bitcast i8* %20 to i32* + %22 = addrspacecast i32* %21 to i32 addrspace(1)* + store i32 %1, i32 addrspace(1)* %22, align 4 + %23 = getelementptr inbounds i8, i8* %2, i64 28 + %24 = bitcast i8* %23 to i32* + %25 = addrspacecast i32* %24 to i32 addrspace(1)* + store i32 %0, i32 addrspace(1)* %25, align 4 + %26 = getelementptr inbounds i8, i8* %2, i64 32 + %27 = addrspacecast i8* %26 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noundef align 1 dereferenceable(7) %27, i8 addrspace(4)* noundef align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.1, i64 0, i64 0), i64 7, i1 false) + %28 = getelementptr inbounds i8, i8* %2, i64 39 + %29 = addrspacecast i8* %28 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %29, i8* align 1 %s, i32 %1, i1 false) + %30 = tail call i32 @printf_execute(i8* %2, i32 %total_buffer_size) #2 + ret void +} + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90printl_(i8* %s, i64* nocapture readonly %i) local_unnamed_addr #0 { +entry: + %0 = load i64, i64* %i, align 8, !tbaa !8 + %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %1, 48 + %2 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %3 = bitcast i8* %2 to i32* + %4 = addrspacecast i32* %3 to i32 addrspace(1)* + store i32 40, i32 addrspace(1)* %4, align 4 + %5 = getelementptr inbounds i8, i8* %2, i64 4 + %6 = bitcast i8* %5 to i32* + %7 = addrspacecast i32* %6 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %7, align 4 + %8 = getelementptr inbounds i8, i8* %2, i64 8 + %9 = bitcast i8* %8 to i32* + %10 = addrspacecast i32* %9 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %10, align 4 + %11 = getelementptr inbounds i8, i8* %2, i64 12 + %12 = bitcast i8* %11 to i32* + %13 = addrspacecast i32* %12 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %13, align 4 + %14 = getelementptr inbounds i8, i8* %2, i64 16 + %15 = bitcast i8* %14 to i32* + %16 = addrspacecast i32* %15 to i32 addrspace(1)* + store i32 852032, i32 addrspace(1)* %16, align 4 + %17 = getelementptr inbounds i8, i8* %2, i64 20 + %18 = bitcast i8* %17 to i32* + %19 = addrspacecast i32* %18 to i32 addrspace(1)* + store i32 8, i32 addrspace(1)* %19, align 4 + %20 = getelementptr inbounds i8, i8* %2, i64 24 + %21 = bitcast i8* %20 to i32* + %22 = addrspacecast i32* %21 to i32 addrspace(1)* + store i32 %1, i32 addrspace(1)* %22, align 4 + %23 = getelementptr inbounds i8, i8* %2, i64 32 + %24 = bitcast i8* %23 to i64* + %25 = addrspacecast i64* %24 to i64 addrspace(1)* + store i64 %0, i64 addrspace(1)* %25, align 8 + %26 = getelementptr inbounds i8, i8* %2, i64 40 + %27 = bitcast i8* %26 to i64* + %28 = addrspacecast i64* %27 to i64 addrspace(1)* + store i64 2925165409235749, i64 addrspace(1)* %28, align 1 + %29 = getelementptr inbounds i8, i8* %2, i64 48 + %30 = addrspacecast i8* %29 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %30, i8* align 1 %s, i32 %1, i1 false) + %31 = tail call i32 @printf_execute(i8* %2, i32 %total_buffer_size) #2 + ret void +} + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90printf_(i8* %s, float* nocapture readonly %f) local_unnamed_addr #0 { +entry: + %0 = load float, float* %f, align 4, !tbaa !10 + %conv = fpext float %0 to double + %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %1, 47 + %2 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %3 = bitcast i8* %2 to i32* + %4 = addrspacecast i32* %3 to i32 addrspace(1)* + store i32 40, i32 addrspace(1)* %4, align 4 + %5 = getelementptr inbounds i8, i8* %2, i64 4 + %6 = bitcast i8* %5 to i32* + %7 = addrspacecast i32* %6 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %7, align 4 + %8 = getelementptr inbounds i8, i8* %2, i64 8 + %9 = bitcast i8* %8 to i32* + %10 = addrspacecast i32* %9 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %10, align 4 + %11 = getelementptr inbounds i8, i8* %2, i64 12 + %12 = bitcast i8* %11 to i32* + %13 = addrspacecast i32* %12 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %13, align 4 + %14 = getelementptr inbounds i8, i8* %2, i64 16 + %15 = bitcast i8* %14 to i32* + %16 = addrspacecast i32* %15 to i32 addrspace(1)* + store i32 196672, i32 addrspace(1)* %16, align 4 + %17 = getelementptr inbounds i8, i8* %2, i64 20 + %18 = bitcast i8* %17 to i32* + %19 = addrspacecast i32* %18 to i32 addrspace(1)* + store i32 7, i32 addrspace(1)* %19, align 4 + %20 = getelementptr inbounds i8, i8* %2, i64 24 + %21 = bitcast i8* %20 to i32* + %22 = addrspacecast i32* %21 to i32 addrspace(1)* + store i32 %1, i32 addrspace(1)* %22, align 4 + %23 = getelementptr inbounds i8, i8* %2, i64 32 + %24 = bitcast i8* %23 to double* + %25 = addrspacecast double* %24 to double addrspace(1)* + store double %conv, double addrspace(1)* %25, align 8 + %26 = getelementptr inbounds i8, i8* %2, i64 40 + %27 = addrspacecast i8* %26 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noundef align 1 dereferenceable(7) %27, i8 addrspace(4)* noundef align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.3, i64 0, i64 0), i64 7, i1 false) + %28 = getelementptr inbounds i8, i8* %2, i64 47 + %29 = addrspacecast i8* %28 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %29, i8* align 1 %s, i32 %1, i1 false) + %30 = tail call i32 @printf_execute(i8* %2, i32 %total_buffer_size) #2 + ret void +} + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90printd_(i8* %s, double* nocapture readonly %d) local_unnamed_addr #0 { +entry: + %0 = load double, double* %d, align 8, !tbaa !12 + %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %1, 47 + %2 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %3 = bitcast i8* %2 to i32* + %4 = addrspacecast i32* %3 to i32 addrspace(1)* + store i32 40, i32 addrspace(1)* %4, align 4 + %5 = getelementptr inbounds i8, i8* %2, i64 4 + %6 = bitcast i8* %5 to i32* + %7 = addrspacecast i32* %6 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %7, align 4 + %8 = getelementptr inbounds i8, i8* %2, i64 8 + %9 = bitcast i8* %8 to i32* + %10 = addrspacecast i32* %9 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %10, align 4 + %11 = getelementptr inbounds i8, i8* %2, i64 12 + %12 = bitcast i8* %11 to i32* + %13 = addrspacecast i32* %12 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %13, align 4 + %14 = getelementptr inbounds i8, i8* %2, i64 16 + %15 = bitcast i8* %14 to i32* + %16 = addrspacecast i32* %15 to i32 addrspace(1)* + store i32 196672, i32 addrspace(1)* %16, align 4 + %17 = getelementptr inbounds i8, i8* %2, i64 20 + %18 = bitcast i8* %17 to i32* + %19 = addrspacecast i32* %18 to i32 addrspace(1)* + store i32 7, i32 addrspace(1)* %19, align 4 + %20 = getelementptr inbounds i8, i8* %2, i64 24 + %21 = bitcast i8* %20 to i32* + %22 = addrspacecast i32* %21 to i32 addrspace(1)* + store i32 %1, i32 addrspace(1)* %22, align 4 + %23 = getelementptr inbounds i8, i8* %2, i64 32 + %24 = bitcast i8* %23 to double* + %25 = addrspacecast double* %24 to double addrspace(1)* + store double %0, double addrspace(1)* %25, align 8 + %26 = getelementptr inbounds i8, i8* %2, i64 40 + %27 = addrspacecast i8* %26 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noundef align 1 dereferenceable(7) %27, i8 addrspace(4)* noundef align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.4, i64 0, i64 0), i64 7, i1 false) + %28 = getelementptr inbounds i8, i8* %2, i64 47 + %29 = addrspacecast i8* %28 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %29, i8* align 1 %s, i32 %1, i1 false) + %30 = tail call i32 @printf_execute(i8* %2, i32 %total_buffer_size) #2 + ret void +} + +; Function Attrs: argmemonly nofree nosync nounwind willreturn +declare void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noalias nocapture writeonly, i8 addrspace(4)* noalias nocapture readonly, i64, i1 immarg) #1 + +attributes #0 = { alwaysinline norecurse nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx906" "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot7-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst" } +attributes #1 = { argmemonly nofree nosync nounwind willreturn } +attributes #2 = { nounwind } + +!llvm.module.flags = !{!0, !1} +!opencl.ocl.version = !{!2} +!llvm.ident = !{!3} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 2, i32 0} +!3 = !{!"AOMP_STANDALONE_12.0-0 clang version 13.0.0 (ssh://rlieberm@gerrit-git.amd.com:29418/lightning/ec/llvm-project 25f685d3c7ea9fccd2872f39d7603736a103575e)"} +!4 = !{!5, !5, i64 0} +!5 = !{!"int", !6, i64 0} +!6 = !{!"omnipotent char", !7, i64 0} +!7 = !{!"Simple C/C++ TBAA"} +!8 = !{!9, !9, i64 0} +!9 = !{!"long", !6, i64 0} +!10 = !{!11, !11, i64 0} +!11 = !{!"float", !6, i64 0} +!12 = !{!13, !13, i64 0} +!13 = !{!"double", !6, i64 0} diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 1eec660..67292c4 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -154,19 +154,30 @@ add_custom_command( OUTPUT modulefile.phantom add_custom_target(utils_scripts ALL DEPENDS gpurun.phantom cloc.sh.phantom raja_build.sh.phantom kokkos_build.sh.phantom aompcc.phantom mymcpu.phantom aompversion.phantom clang-ocl.phantom modulefile.phantom aompExtractRegion.phantom) -install(PROGRAMS - ${CMAKE_CURRENT_BINARY_DIR}/cloc.sh - ${CMAKE_CURRENT_BINARY_DIR}/gpurun - ${CMAKE_CURRENT_BINARY_DIR}/raja_build.sh - ${CMAKE_CURRENT_BINARY_DIR}/kokkos_build.sh - ${CMAKE_CURRENT_BINARY_DIR}/aompcc - ${CMAKE_CURRENT_BINARY_DIR}/aompExtractRegion - ${CMAKE_CURRENT_BINARY_DIR}/mymcpu - ${CMAKE_CURRENT_BINARY_DIR}/aompversion - ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu - ${CMAKE_CURRENT_SOURCE_DIR}/bin/openmpi_set_cu_mask - ${CMAKE_CURRENT_SOURCE_DIR}/bin/blt.patch - ${CMAKE_CURRENT_SOURCE_DIR}/bin/raja.patch - ${CMAKE_CURRENT_BINARY_DIR}/clang-ocl - ${CMAKE_CURRENT_BINARY_DIR}/modulefile +if(${AOMP_STANDALONE_BUILD}) + install(PROGRAMS + ${CMAKE_CURRENT_BINARY_DIR}/cloc.sh + ${CMAKE_CURRENT_BINARY_DIR}/gpurun + ${CMAKE_CURRENT_BINARY_DIR}/raja_build.sh + ${CMAKE_CURRENT_BINARY_DIR}/kokkos_build.sh + ${CMAKE_CURRENT_BINARY_DIR}/aompcc + ${CMAKE_CURRENT_BINARY_DIR}/aompExtractRegion + ${CMAKE_CURRENT_BINARY_DIR}/mymcpu + ${CMAKE_CURRENT_BINARY_DIR}/aompversion + ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu + ${CMAKE_CURRENT_SOURCE_DIR}/bin/openmpi_set_cu_mask + ${CMAKE_CURRENT_SOURCE_DIR}/bin/blt.patch + ${CMAKE_CURRENT_SOURCE_DIR}/bin/raja.patch + ${CMAKE_CURRENT_BINARY_DIR}/clang-ocl + ${CMAKE_CURRENT_BINARY_DIR}/modulefile + DESTINATION "${CMAKE_INSTALL_BINDIR}") + +else() + install(PROGRAMS + ${CMAKE_CURRENT_BINARY_DIR}/mymcpu + ${CMAKE_CURRENT_BINARY_DIR}/aompcc + ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu + ${CMAKE_CURRENT_SOURCE_DIR}/bin/openmpi_set_cu_mask + ${CMAKE_CURRENT_BINARY_DIR}/gpurun DESTINATION "${DEVEL_PACKAGE}${CMAKE_INSTALL_BINDIR}") +endif() diff --git a/utils/bin/aompcc b/utils/bin/aompcc index de8a4ac..4caa747 100755 --- a/utils/bin/aompcc +++ b/utils/bin/aompcc @@ -2,10 +2,9 @@ # # aompcc: Wrapper (driver) for the AOMP compiler. # The goal of this wrapper is to have a simplified interface for -# all languages and options supported by AOMP. +# compiling for openmp target offload. # # Written by Greg Rodgers Gregory.Rodgers@amd.com -# PROGVERSION="X.Y-Z" # # Copyright(C) 2020 Advanced Micro Devices, Inc. All rights reserved. @@ -56,17 +55,13 @@ function usage(){ aompcc: Wrapper (driver) for the AOMP compiler. The goal of this wrapper is to have a simplified interface - for all languages and options supported by AOMP. + for compiling openmp target offload. Usage: aompcc [ options ] input-files - hipcc: Symbolic link to aompcc to treat c and cpp input files as if hip - Usage: hipcc [ options ] input-files - Options without values: - -ll Generate LLVM IR for compiler passes - -s Generate dissassembled gcn -g Generate debug information -version Display version of aompcc then exit + --version Display version of aompcc then exit -v Verbose, just print commands -vv Very verbose, pass -v to commands -n Dryrun, do nothing, show commands that would execute @@ -76,7 +71,6 @@ function usage(){ Options with values: -aomp $AOMP or _AOMP_INSTALL_DIR_ - -cuda-path $CUDA_PATH or /usr/local/cuda -I Provide one directory per -I option -O LLVM optimization level -o Default=a.out @@ -86,12 +80,11 @@ function usage(){ Examples: aompcc my.c /* Compiles with OpenMP to create a.out */ - aompcc my.hip -o myhip /* Compiles with HIP to create myhip */ Note: Instead of providing these command line options: - -aomp, -cuda-path, --offload-arch, + -aomp, --offload-arch, you may set these environment variables, respectively: - AOMP, CUDA_PATH, AOMP_GPU + AOMP, AOMP_GPU Command line options take precedence over environment variables. @@ -184,14 +177,10 @@ while [ $# -gt 0 ] ; do --quiet) QUIET=true;; -k) KEEPTDIR=true;; -n) DRYRUN=true;; - -c) GEN_OBJECT_ONLY=true;; - -g) GEN_DEBUG=true;; - -ll) GENLL=true;; - -s) GENASM=true;; + -c) GEN_OBJECT_ONLY=true;; + -g) GEN_DEBUG=true;; -noqp) NOQP=true;; - -cl12) CL12=true;; -noshared) NOSHARED=true;; - -cuopts) CUOPTS=$2; shift ;; -I) INCLUDES="$INCLUDES -I $2"; shift ;; -O) LLVMOPT=$2; shift ;; -O3) LLVMOPT=3 ;; @@ -263,7 +252,6 @@ if [ ! -d $AOMP ] ; then fi TARGET_TRIPLE=${TARGET_TRIPLE:-amdgcn-amd-amdhsa} -CUDA_PATH=${CUDA_PATH:-/usr/local/cuda} # Determine which gfx processor to use. if [ ! $AOMP_GPU ] ; then @@ -275,10 +263,6 @@ if [ ! $AOMP_GPU ] ; then fi fi -if [ "${AOMP_GPU:0:3}" == "sm_" ] ; then - TARGET_TRIPLE="nvptx64-nvidia-cuda" -fi - LLVMOPT=${LLVMOPT:-3} if [ $VV ] ; then @@ -341,7 +325,6 @@ fi # Print Header block if [ $VERBOSE ] ; then echo "# " - echo "#Info: AOMP Version: $PROGVERSION" echo "#Info: AOMP Path: $AOMP/bin" echo "#Info: How called: $HOW_CALLED" echo "#Info: Run date: $RUNDATE" @@ -418,20 +401,12 @@ fi if [ $GEN_DEBUG ] ; then CLANG_ARGS=" -g $CLANG_ARGS" fi -if [ $VV ] ; then +if [ $VV ] ; then CLANG_ARGS=" -v $CLANG_ARGS" fi -if [ $GEN_OBJECT_ONLY ] ; then +if [ $GEN_OBJECT_ONLY ] ; then CLANG_ARGS=" -c $CLANG_ARGS" fi -if [ $GENLL ] ; then - echo "ERROR: -ll option not supported yet" - exit $DEADRC -fi -if [ $GENASM ] ; then - echo "ERROR: -s option not supported yet" - exit $DEADRC -fi __INPUTS="" IFS=, @@ -457,32 +432,6 @@ __ADJUSTEDINPUTS=$(echo $__INPUTS | sed "s/^[[:space:]]//") runcmd "$COMPILER_BIN_DIR/$CLANG_CMD $CLANG_ARGS $PASSTHRUARGS -o " "$OUTDIR/$OUTFILE" "$__ADJUSTEDINPUTS" -# FIXME: This needs to be cleaned up and tested -if [ $GENLL ] ; then - runcmd "$AOMP/bin/llvm-dis -o $TMPDIR/$FNAME.ll $TMPDIR/$FNAME.bc" - if [ "$OUTDIR" != "$TMPDIR" ] ; then - runcmd "cp $TMPDIR/$FNAME.ll $OUTDIR/$FNAME.ll" - fi -fi - -# FIXME: This needs to be cleaned up and tested -if [ $GENASM ] ; then - textstarthex=`readelf -S -W $OUTDIR/$OUTFILE | grep .text | awk '{print $6}'` - textstart=$((0x$textstarthex)) - textszhex=`readelf -S -W $OUTDIR/$OUTFILE | grep .text | awk '{print $7}'` - textsz=$((0x$textszhex)) - countclause=" count=$textsz skip=$textstart" - dd if=$OUTDIR/$OUTFILE of=$OUTDIR/$FNAME.raw bs=1 $countclause 2>/dev/null - hexdump -v -e '/1 "0x%02X "' $OUTDIR/$FNAME.raw | $AOMP/bin/llvm-mc -arch=amdgcn -offload-arch=$AOMP_GPU -disassemble >$OUTDIR/$FNAME.s 2>$OUTDIR/$FNAME.s.err - rm $OUTDIR/$FNAME.raw - if [ "$AOMP_GPU" == "kaveri" ] ; then - echo "WARNING: Disassembly not supported for Kaveri. See $FNAME.s.err" - else - rm $OUTDIR/$FNAME.s.err - echo "#INFO File $OUTDIR/$FNAME.s contains amdgcn assembly" - fi -fi - # cleanup do_err 0 exit 0 diff --git a/utils/bin/gpurun b/utils/bin/gpurun index 7296fcd..bb5f29b 100755 --- a/utils/bin/gpurun +++ b/utils/bin/gpurun @@ -1,4 +1,23 @@ #!/bin/bash +# Copyright(C) 2021 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. # # gpurun: Process launch utility for GPU applications. This is a wrapper # to execute a GPU application including OpenMPI GPU applications. @@ -27,40 +46,6 @@ # - Add support for other mpi launchers besides openmpi's mpirun. # - If gpurun becomes popular, convert this script to a program # -# Copyright(C) 2021 Advanced Micro Devices, Inc. All rights reserved. -# -# AMD is granting you permission to use this software and documentation (if any) (collectively, the -# Materials) pursuant to the terms and conditions of the Software License Agreement included with the -# Materials. If you do not have a copy of the Software License Agreement, contact your AMD -# representative for a copy. -# -# WARRANTY DISCLAIMER: THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY -# KIND. AMD DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT -# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, TITLE, NON-INFRINGEMENT, THAT THE SOFTWARE WILL RUN UNINTERRUPTED OR ERROR- -# FREE OR WARRANTIES ARISING FROM CUSTOM OF TRADE OR COURSE OF USAGE. THE ENTIRE RISK -# ASSOCIATED WITH THE USE OF THE SOFTWARE IS ASSUMED BY YOU. Some jurisdictions do not -# allow the exclusion of implied warranties, so the above exclusion may not apply to You. -# -# LIMITATION OF LIABILITY AND INDEMNIFICATION: AMD AND ITS LICENSORS WILL NOT, -# UNDER ANY CIRCUMSTANCES BE LIABLE TO YOU FOR ANY PUNITIVE, DIRECT, INCIDENTAL, -# INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM USE OF THE SOFTWARE OR THIS -# AGREEMENT EVEN IF AMD AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH -# DAMAGES. In no event shall AMD's total liability to You for all damages, losses, and -# causes of action (whether in contract, tort (including negligence) or otherwise) -# exceed the amount of $100 USD. You agree to defend, indemnify and hold harmless -# AMD and its licensors, and any of their directors, officers, employees, affiliates or -# agents from and against any and all loss, damage, liability and other expenses -# (including reasonable attorneys' fees), resulting from Your use of the Software or -# violation of the terms and conditions of this Agreement. -# -# U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with "RESTRICTED RIGHTS." -# Use, duplication, or disclosure by the Government is subject to the restrictions as set -# forth in FAR 52.227-14 and DFAR252.227-7013, et seq., or its successor. Use of the -# Materials by the Government constitutes acknowledgement of AMD's proprietary rights in them. -# -# EXPORT RESTRICTIONS: The Materials may be subject to export restrictions as stated in the -# Software License Agreement. PROGVERSION=X.Y-Z function version(){ @@ -346,6 +331,7 @@ fi NUMANODE=`cat /sys/bus/pci/devices/0000:$_bdfidstrc.0/numa_node` # Sometimes lscpu shows 0 for the node, when /sys/bus/pci/.. shows -1 [[ $NUMANODE == -1 ]] && NUMANODE=0 +[[ "$NUMANODE" == "" ]] && NUMANODE=0 _taskset_cmd="taskset -c " lscpu --extended=cpu,node >$_tfile while read _linepair ; do diff --git a/utils/bin/kokkos_build.sh b/utils/bin/kokkos_build.sh index ede9606..2be87f7 100755 --- a/utils/bin/kokkos_build.sh +++ b/utils/bin/kokkos_build.sh @@ -1,4 +1,23 @@ #!/bin/bash +# Copyright(C) 2020 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. # # kokkos_build.sh: Script to clone and build kokkos for a specific GPU # This will build kokkos in directory $HOME/kokkos_build. @@ -8,44 +27,6 @@ # PROGVERSION="X.Y-Z" # -# Copyright(C) 2020 Advanced Micro Devices, Inc. All rights reserved. -# -# AMD is granting you permission to use this software and documentation (if any) (collectively, the -# Materials) pursuant to the terms and conditions of the Software License Agreement included with the -# Materials. If you do not have a copy of the Software License Agreement, contact your AMD -# representative for a copy. -# -# You agree that you will not reverse engineer or decompile the Materials, in whole or in part, except for -# example code which is provided in source code form and as allowed by applicable law. -# -# WARRANTY DISCLAIMER: THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY -# KIND. AMD DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT -# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, TITLE, NON-INFRINGEMENT, THAT THE SOFTWARE WILL RUN UNINTERRUPTED OR ERROR- -# FREE OR WARRANTIES ARISING FROM CUSTOM OF TRADE OR COURSE OF USAGE. THE ENTIRE RISK -# ASSOCIATED WITH THE USE OF THE SOFTWARE IS ASSUMED BY YOU. Some jurisdictions do not -# allow the exclusion of implied warranties, so the above exclusion may not apply to You. -# -# LIMITATION OF LIABILITY AND INDEMNIFICATION: AMD AND ITS LICENSORS WILL NOT, -# UNDER ANY CIRCUMSTANCES BE LIABLE TO YOU FOR ANY PUNITIVE, DIRECT, INCIDENTAL, -# INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM USE OF THE SOFTWARE OR THIS -# AGREEMENT EVEN IF AMD AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH -# DAMAGES. In no event shall AMD's total liability to You for all damages, losses, and -# causes of action (whether in contract, tort (including negligence) or otherwise) -# exceed the amount of $100 USD. You agree to defend, indemnify and hold harmless -# AMD and its licensors, and any of their directors, officers, employees, affiliates or -# agents from and against any and all loss, damage, liability and other expenses -# (including reasonable attorneys' fees), resulting from Your use of the Software or -# violation of the terms and conditions of this Agreement. -# -# U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with "RESTRICTED RIGHTS." -# Use, duplication, or disclosure by the Government is subject to the restrictions as set -# forth in FAR 52.227-14 and DFAR252.227-7013, et seq., or its successor. Use of the -# Materials by the Government constitutes acknowledgement of AMD's proprietary rights in them. -# -# EXPORT RESTRICTIONS: The Materials may be subject to export restrictions as stated in the -# Software License Agreement. -# AOMP=${AOMP:-_AOMP_INSTALL_DIR_} if [ ! -d $AOMP ] ; then