1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 // Common DSO loading functionality: exposes callables that dlopen DSOs 17 // in either the runfiles directories 18 19 #ifndef TENSORFLOW_STREAM_EXECUTOR_DSO_LOADER_H_ 20 #define TENSORFLOW_STREAM_EXECUTOR_DSO_LOADER_H_ 21 22 #include <vector> 23 #include "tensorflow/stream_executor/platform/port.h" 24 25 #include "absl/strings/string_view.h" 26 #include "tensorflow/stream_executor/lib/status.h" 27 #include "tensorflow/stream_executor/lib/statusor.h" 28 #include "tensorflow/stream_executor/platform.h" 29 #include "tensorflow/stream_executor/platform/mutex.h" 30 31 namespace stream_executor { 32 namespace internal { 33 34 namespace DsoLoader { 35 // The following methods either load the DSO of interest and return a dlopen 36 // handle or error status. 37 port::StatusOr<void*> GetCudaDriverDsoHandle(); 38 port::StatusOr<void*> GetCudaRuntimeDsoHandle(); 39 port::StatusOr<void*> GetCublasDsoHandle(); 40 port::StatusOr<void*> GetCufftDsoHandle(); 41 port::StatusOr<void*> GetCurandDsoHandle(); 42 port::StatusOr<void*> GetCuptiDsoHandle(); 43 port::StatusOr<void*> GetCudnnDsoHandle(); 44 45 port::StatusOr<void*> GetRocblasDsoHandle(); 46 port::StatusOr<void*> GetMiopenDsoHandle(); 47 port::StatusOr<void*> GetRocfftDsoHandle(); 48 port::StatusOr<void*> GetRocrandDsoHandle(); 49 port::StatusOr<void*> GetHipDsoHandle(); 50 } // namespace DsoLoader 51 52 // Wrapper around the DsoLoader that prevents us from dlopen'ing any of the DSOs 53 // more than once. 54 namespace CachedDsoLoader { 55 // Cached versions of the corresponding DsoLoader methods above. 56 port::StatusOr<void*> GetCudaDriverDsoHandle(); 57 port::StatusOr<void*> GetCudaRuntimeDsoHandle(); 58 port::StatusOr<void*> GetCublasDsoHandle(); 59 port::StatusOr<void*> GetCufftDsoHandle(); 60 port::StatusOr<void*> GetCurandDsoHandle(); 61 port::StatusOr<void*> GetCuptiDsoHandle(); 62 port::StatusOr<void*> GetCudnnDsoHandle(); 63 64 port::StatusOr<void*> GetRocblasDsoHandle(); 65 port::StatusOr<void*> GetMiopenDsoHandle(); 66 port::StatusOr<void*> GetRocfftDsoHandle(); 67 port::StatusOr<void*> GetRocrandDsoHandle(); 68 port::StatusOr<void*> GetHipDsoHandle(); 69 } // namespace CachedDsoLoader 70 71 } // namespace internal 72 } // namespace stream_executor 73 74 #endif // TENSORFLOW_STREAM_EXECUTOR_DSO_LOADER_H_ 75