1/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 3Licensed under the Apache License, Version 2.0 (the "License"); 4you may not use this file except in compliance with the License. 5You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9Unless required by applicable law or agreed to in writing, software 10distributed under the License is distributed on an "AS IS" BASIS, 11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12See the License for the specific language governing permissions and 13limitations under the License. 14==============================================================================*/ 15 16#include "tensorflow/stream_executor/cuda/cuda_activation.h" 17 18#include "tensorflow/stream_executor/cuda/cuda_driver.h" 19#include "tensorflow/stream_executor/stream_executor.h" 20#include "tensorflow/stream_executor/stream_executor_internal.h" 21 22namespace perftools { 23namespace gputools { 24namespace cuda { 25 26CudaContext* ExtractCudaContext(CUDAExecutor *cuda_exec); 27CUDAExecutor *ExtractCudaExecutor(StreamExecutor *stream_exec); 28 29ScopedActivateExecutorContext::ScopedActivateExecutorContext( 30 CUDAExecutor *cuda_exec): 31 driver_scoped_activate_context_( 32 new ScopedActivateContext{ExtractCudaContext(cuda_exec)}) { } 33 34ScopedActivateExecutorContext::ScopedActivateExecutorContext( 35 StreamExecutor *stream_exec) 36 : ScopedActivateExecutorContext(ExtractCudaExecutor(stream_exec)) {} 37 38ScopedActivateExecutorContext::~ScopedActivateExecutorContext() { 39 delete static_cast<ScopedActivateContext *>(driver_scoped_activate_context_); 40} 41 42} // namespace cuda 43} // namespace gputools 44} // namespace perftools 45