Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ option(FLANG_CUF_RUNTIME
"Compile CUDA Fortran runtime sources" OFF)
if (FLANG_CUF_RUNTIME)
find_package(CUDAToolkit REQUIRED)
add_compile_definitions(FLANG_CUDA_SUPPORT=1)
endif()

add_subdirectory(include)
Expand Down
1 change: 0 additions & 1 deletion flang/include/flang/Runtime/CUDA/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef FORTRAN_RUNTIME_CUDA_INIT_H_
#define FORTRAN_RUNTIME_CUDA_INIT_H_

#include "common.h"
#include "flang/Runtime/entry-names.h"

extern "C" {
Expand Down
6 changes: 1 addition & 5 deletions flang/lib/Optimizer/Builder/Runtime/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Runtime/CUDA/init.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
#ifdef FLANG_CUDA_SUPPORT
#include "flang/Runtime/CUDA/init.h"
#endif

using namespace Fortran::runtime;

Expand Down Expand Up @@ -66,13 +64,11 @@ void fir::runtime::genMain(

builder.create<fir::CallOp>(loc, startFn, args);

#ifdef FLANG_CUDA_SUPPORT
if (initCuda) {
auto initFn = builder.createFunction(
loc, RTNAME_STRING(CUFInit), mlir::FunctionType::get(context, {}, {}));
builder.create<fir::CallOp>(loc, initFn);
}
#endif

builder.create<fir::CallOp>(loc, qqMainFn);
builder.create<fir::CallOp>(loc, stopFn);
Expand Down
11 changes: 11 additions & 0 deletions flang/test/Lower/CUDA/cuda-init.cuf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
! RUN: bbc -emit-fir -hlfir -fcuda %s -o - | FileCheck %s --check-prefixes=ALL,CUDA
! RUN: bbc -emit-fir -hlfir %s -o - | FileCheck %s --check-prefixes=ALL,NOCUDA

program test_init

end

! ALL-LABEL: func.func @main
! ALL: fir.call @_FortranAProgramStart
! CUDA: fir.call @_FortranACUFInit() fastmath<contract> : () -> ()
! NOCUDA-NOT: fir.call @_FortranACUFInit() fastmath<contract> : () -> ()