-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[flang][cuda] Allow to set the stack limit size #124859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- include/flang/Runtime/CUDA/init.h -----------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef FORTRAN_RUNTIME_CUDA_INIT_H_ | ||
| #define FORTRAN_RUNTIME_CUDA_INIT_H_ | ||
|
|
||
| #include "common.h" | ||
| #include "flang/Runtime/entry-names.h" | ||
|
|
||
| extern "C" { | ||
|
|
||
| void RTDECL(CUFInit)(); | ||
| } | ||
|
|
||
| #endif // FORTRAN_RUNTIME_CUDA_INIT_H_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,13 +16,17 @@ | |
| #include "flang/Optimizer/Dialect/FIRType.h" | ||
| #include "flang/Runtime/main.h" | ||
| #include "flang/Runtime/stop.h" | ||
| #ifdef FLANG_CUDA_SUPPORT | ||
| #include "flang/Runtime/CUDA/init.h" | ||
| #endif | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason for protecting this include with an ifdef, if this header contains only a runtime signature, it does not seem like it require some CUDA support when building flang. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The header is not present if the cuda fortran rubtime is not compiled
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whether the build configuration compiles CUFRuntime or not,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's correct |
||
|
|
||
| using namespace Fortran::runtime; | ||
|
|
||
| /// Create a `int main(...)` that calls the Fortran entry point | ||
| void fir::runtime::genMain( | ||
| fir::FirOpBuilder &builder, mlir::Location loc, | ||
| const std::vector<Fortran::lower::EnvironmentDefault> &defs) { | ||
| const std::vector<Fortran::lower::EnvironmentDefault> &defs, | ||
| bool initCuda) { | ||
| auto *context = builder.getContext(); | ||
| auto argcTy = builder.getDefaultIntegerType(); | ||
| auto ptrTy = mlir::LLVM::LLVMPointerType::get(context); | ||
|
|
@@ -61,6 +65,15 @@ void fir::runtime::genMain( | |
| args.push_back(env); | ||
|
|
||
| builder.create<fir::CallOp>(loc, startFn, args); | ||
|
|
||
| #ifdef FLANG_CUDA_SUPPORT | ||
| if (initCuda) { | ||
| auto initFn = builder.createFunction( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What should happen in the following cases?
|
||
| 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); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- runtime/CUDA/init.cpp ---------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "flang/Runtime/CUDA/init.h" | ||
| #include "../environment.h" | ||
| #include "../terminator.h" | ||
| #include "flang/Runtime/CUDA/common.h" | ||
|
|
||
| #include "cuda_runtime.h" | ||
|
|
||
| extern "C" { | ||
|
|
||
| void RTDEF(CUFInit)() { | ||
| // Perform ctx initialization based on execution environment if necessary. | ||
| if (Fortran::runtime::executionEnvironment.cudaStackLimit) { | ||
| CUDA_REPORT_IF_ERROR(cudaDeviceSetLimit(cudaLimitStackSize, | ||
| Fortran::runtime::executionEnvironment.cudaStackLimit)); | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.