Valentin Clement (バレンタイン クレメン) 1b2196bd82
[flang][cuda] Add entry point for set/get default stream (#181440)
2026-02-13 17:59:06 -08:00

28 lines
948 B
C++

//===-- unittests/Runtime/CUDA/DefaultStream.cpp ----------------*- 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
//
//===----------------------------------------------------------------------===//
#include "cuda_runtime.h"
#include "gtest/gtest.h"
#include "flang/Runtime/CUDA/allocator.h"
using namespace Fortran::runtime;
using namespace Fortran::runtime::cuda;
TEST(DefaultStreamTest, GetAndSetTest) {
using Fortran::common::TypeCategory;
cudaStream_t defaultStream = RTDECL(CUFGetDefaultStream)();
EXPECT_EQ(defaultStream, nullptr);
cudaStream_t stream;
cudaStreamCreate(&stream);
EXPECT_EQ(cudaSuccess, cudaGetLastError());
RTDECL(CUFSetDefaultStream)(stream);
cudaStream_t outStream = RTDECL(CUFGetDefaultStream)();
EXPECT_EQ(outStream, stream);
}