Skip to content

Commit

Permalink
[NVIDIA] Enable clang format (openvinotoolkit#716)
Browse files Browse the repository at this point in the history
* [NVIDIA] Enable clang format

* [NVIDIA] Format code
  • Loading branch information
nkogteva authored Sep 6, 2023
1 parent 2046995 commit 6ab3bf4
Show file tree
Hide file tree
Showing 111 changed files with 1,101 additions and 1,036 deletions.
16 changes: 8 additions & 8 deletions modules/nvidia_plugin/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ set(HEADER_MASKS *.hpp *.cuh)

file(GLOB_RECURSE
SOURCES
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
CONFIGURE_DEPENDS
${SOURCE_MASKS}
)
list(REMOVE_ITEM SOURCES cuda_create_plugin.cpp cuda_create_extensions.cpp)
list(FILTER SOURCES EXCLUDE REGEX "^ops/examples/.*$")
list(FILTER SOURCES EXCLUDE REGEX ".*cuda_create_plugin\\.cpp$")
list(FILTER SOURCES EXCLUDE REGEX ".*cuda_create_extensions\\.cpp$")
list(FILTER SOURCES EXCLUDE REGEX ".*ops/examples/.*$")
file(GLOB_RECURSE
HEADERS
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
${HEADER_MASKS}
)

Expand All @@ -32,14 +31,15 @@ if(ENABLE_PROXY)
endif()

# Adds a shared library with plugin
ie_add_plugin(NAME ${TARGET_NAME}
ov_add_plugin(NAME ${TARGET_NAME}
DEVICE_NAME "NVIDIA"
SOURCES ${HEADERS} cuda_create_plugin.cpp cuda_create_extensions.cpp
DEFAULT_CONFIG ${PLUGIN_DEFAULT_CONFIG}
VERSION_DEFINES_FOR cuda_create_plugin.cpp)
VERSION_DEFINES_FOR cuda_create_plugin.cpp
ADD_CLANG_FORMAT)

# Enable support of CC for the plugin
ie_mark_target_as_cc(${TARGET_NAME})
ov_mark_target_as_cc(${TARGET_NAME})

set_property(TARGET ${OBJ_NAME} PROPERTY CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES})

Expand Down Expand Up @@ -77,6 +77,6 @@ target_link_libraries(${OBJ_NAME}

# ATTENTION: uncomment to register a plugin in the plugins.xml file
if(ENABLE_NVIDIA)
ie_register_plugins(MAIN_TARGET ${TARGET_NAME}
ov_register_plugins(MAIN_TARGET ${TARGET_NAME}
POSSIBLE_PLUGINS ${TARGET_NAME})
endif()
21 changes: 13 additions & 8 deletions modules/nvidia_plugin/src/cuda/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

#pragma once

#include "runtime.hpp"
#include <optional>

#include "runtime.hpp"

namespace CUDA {

class GraphCapture;
class CaptureInfo;

class Graph: public Handle<cudaGraph_t> {
class Graph : public Handle<cudaGraph_t> {
public:
Graph(unsigned int flags);

Expand All @@ -23,14 +24,14 @@ class Graph: public Handle<cudaGraph_t> {
private:
Graph(cudaGraph_t graph);

static cudaError_t createFromNative(cudaGraph_t *pGraph, cudaGraph_t anotherGraph);
static cudaError_t createFromNative(cudaGraph_t* pGraph, cudaGraph_t anotherGraph);

static cudaGraph_t createNativeWithFlags(unsigned int flags);
};

bool operator==(const Graph& rhs, const Graph& lhs);

class GraphExec: public Handle<cudaGraphExec_t> {
class GraphExec : public Handle<cudaGraphExec_t> {
public:
GraphExec(const Graph& g);

Expand Down Expand Up @@ -73,16 +74,18 @@ class GraphCapture {

private:
Stream stream_;
cudaGraph_t cudaGraph_ {};
cudaError_t capturedError_ {cudaSuccess};
std::optional<Graph> graph_ {};
cudaGraph_t cudaGraph_{};
cudaError_t capturedError_{cudaSuccess};
std::optional<Graph> graph_{};
};

class UploadNode {
friend CaptureInfo;

public:
void update_src(const GraphExec& exec, const void* src);
bool operator==(const UploadNode& rhs) const;

private:
UploadNode(cudaGraphNode_t node, CUDA::DevicePointer<void*> dst, const void* src, std::size_t size);
cudaGraphNode_t node_;
Expand All @@ -93,9 +96,11 @@ class UploadNode {

class DownloadNode {
friend CaptureInfo;

public:
void update_dst(const GraphExec& exec, void* dst);
bool operator==(const DownloadNode& rhs) const;

private:
DownloadNode(cudaGraphNode_t node, void* dst, CUDA::DevicePointer<const void*> src, std::size_t size);
cudaGraphNode_t node_;
Expand All @@ -118,4 +123,4 @@ class CaptureInfo {
size_t depCount_;
};

}// namespace CUDA
} // namespace CUDA
3 changes: 1 addition & 2 deletions modules/nvidia_plugin/src/cuda_async_infer_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

#pragma once

#include "cuda_infer_request.hpp"
#include "openvino/runtime/iasync_infer_request.hpp"
#include "openvino/runtime/iinfer_request.hpp"

#include "cuda_infer_request.hpp"

namespace ov {
namespace nvidia_gpu {

Expand Down
3 changes: 2 additions & 1 deletion modules/nvidia_plugin/src/cuda_eager_topology_runner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <ops/subgraph.hpp>

#include "cuda_itopology_runner.hpp"

namespace ov {
Expand All @@ -16,7 +17,7 @@ class EagerTopologyRunner final : public SubGraph, public ITopologyRunner {
~EagerTopologyRunner() override = default;

void Run(const InferenceRequestContext& context, const DeviceMemBlock& memoryBlock) const override;
void UpdateContext(InferenceRequestContext& context, const DeviceMemBlock& memoryBlock) const override {};
void UpdateContext(InferenceRequestContext& context, const DeviceMemBlock& memoryBlock) const override{};
const SubGraph& GetSubGraph() const override;
};

Expand Down
1 change: 1 addition & 0 deletions modules/nvidia_plugin/src/cuda_graph_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <cuda/graph.hpp>

#include "cuda_tensor_mapping_context.hpp"

namespace ov {
Expand Down
16 changes: 7 additions & 9 deletions modules/nvidia_plugin/src/cuda_infer_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@
#include <unordered_map>
#include <vector>


#include "openvino/runtime/tensor.hpp"
#include "openvino/runtime/isync_infer_request.hpp"
#include "openvino/itt.hpp"


#include "cancellation_token.hpp"
#include "cuda_config.hpp"
#include "cuda_operation_base.hpp"
#include "cuda_iexecution_delegator.hpp"
#include "cuda_operation_base.hpp"
#include "memory_manager/cuda_memory_manager.hpp"
#include "memory_manager/cuda_memory_pool.hpp"
#include "openvino/itt.hpp"
#include "openvino/runtime/isync_infer_request.hpp"
#include "openvino/runtime/tensor.hpp"
#include "utils/perf_timing.hpp"

namespace ov {
Expand All @@ -33,7 +30,7 @@ namespace nvidia_gpu {
class CompiledModel;

// ! [infer_request:header]
class CudaInferRequest : public ov::ISyncInferRequest {
class CudaInferRequest : public ov::ISyncInferRequest {
public:
using Ptr = std::shared_ptr<CudaInferRequest>;

Expand All @@ -52,7 +49,8 @@ class CudaInferRequest : public ov::ISyncInferRequest {
void infer_postprocess();
void cancel();

void set_tensors_impl(const ov::Output<const ov::Node> port, const std::vector<ov::SoPtr<ov::ITensor>>& tensors) override;
void set_tensors_impl(const ov::Output<const ov::Node> port,
const std::vector<ov::SoPtr<ov::ITensor>>& tensors) override;

private:
std::shared_ptr<const CompiledModel> get_nvidia_model();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <memory_manager/cuda_device_mem_block.hpp>

#include "cancellation_token.hpp"
#include "cuda_graph_context.hpp"
#include "cuda_tensor_mapping_context.hpp"
#include "cuda_thread_context.hpp"
#include "cuda_graph_context.hpp"

namespace ov {
namespace nvidia_gpu {
Expand Down
2 changes: 1 addition & 1 deletion modules/nvidia_plugin/src/cuda_op_buffers_extractor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include <unordered_map>
#include <vector>

#include "openvino/core/node.hpp"
#include "memory_manager/cuda_workbuffers.hpp"
#include "openvino/core/node.hpp"

namespace ov {
namespace nvidia_gpu {
Expand Down
15 changes: 8 additions & 7 deletions modules/nvidia_plugin/src/cuda_operation_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@ class OperationRegistry::Register<OperationBase> {
* where NodeOp is a type's inner alias for a concrete OpenVINO Node class
* @param name - a textual operator's name
*/
#define OPERATION_REGISTER(type, name) \
extern "C" { \
[[maybe_unused]] const ::ov::nvidia_gpu::OperationRegistry::Register<type> openvino_cuda_op_register_##name{#name}; \
#define OPERATION_REGISTER(type, name) \
extern "C" { \
[[maybe_unused]] const ::ov::nvidia_gpu::OperationRegistry::Register<type> openvino_cuda_op_register_##name{ \
#name}; \
}

#define OPERATION_REGISTER_FACTORY(factory, name) \
extern "C" { \
[[maybe_unused]] const ::ov::nvidia_gpu::OperationRegistry::Register<OperationBase> openvino_cuda_op_register_##name{ \
#name, factory}; \
#define OPERATION_REGISTER_FACTORY(factory, name) \
extern "C" { \
[[maybe_unused]] const ::ov::nvidia_gpu::OperationRegistry::Register<OperationBase> \
openvino_cuda_op_register_##name{#name, factory}; \
}
7 changes: 3 additions & 4 deletions modules/nvidia_plugin/src/cuda_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

#pragma once

#include "cuda_compiled_model.hpp"
#include "cuda_config.hpp"
#include "cuda_thread_pool.hpp"
#include "openvino/runtime/icompiled_model.hpp"
#include "openvino/runtime/iplugin.hpp"
#include "openvino/runtime/threading/itask_executor.hpp"

#include "cuda_config.hpp"
#include "cuda_compiled_model.hpp"
#include "cuda_thread_pool.hpp"
#include "transformer/cuda_graph_transformer.hpp"

namespace ov {
Expand Down
6 changes: 3 additions & 3 deletions modules/nvidia_plugin/src/cuda_profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class Profiler : public IExecutionDelegator {

void collect_subgraphs(const SubGraph& graph, std::vector<OperationBase::Ptr>& vector);
void collect_node_visitor(const OperationBase::Ptr& execStep,
std::vector<ProfileExecStep>& perfSteps,
std::vector<OperationBase::Ptr>& allExecSequence);
std::vector<ProfileExecStep>& perfSteps,
std::vector<OperationBase::Ptr>& allExecSequence);

const CUDA::Stream* active_stream_ = nullptr;
std::vector<std::pair<const void*, std::vector<ProfileExecStep>>> subgraph_perf_steps_map_;
Expand All @@ -109,7 +109,7 @@ class Profiler : public IExecutionDelegator {
std::array<Duration, static_cast<std::size_t>(PerfStages::NumOfStages)> durations_;
Time::time_point start_{};
size_t infer_count_{};
CUDA::Event::RecordMode cuda_event_record_mode_ {CUDA::Event::RecordMode::Default};
CUDA::Event::RecordMode cuda_event_record_mode_{CUDA::Event::RecordMode::Default};
};

class Profiler::ProfileExecStep {
Expand Down
2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/abs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Abs {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/cos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Cos {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/cosh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Cosh {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


8 changes: 4 additions & 4 deletions modules/nvidia_plugin/src/kernels/details/typed_functor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ struct TypedFunctor : private std::array<TypedFunctor<TFunctor, TFunPtr, Dimensi
const size_t type_idx = static_cast<size_t>(type) - type_t_first_value;
if (type_idx >= this->size()) {
throw_ov_exception(fmt::format("TypedFunctor[Dimension={}]: Type = {} is not supported by TypedFunctor !!",
DIM_1D,
static_cast<Type_t>(type_idx)));
DIM_1D,
static_cast<Type_t>(type_idx)));
}
return std::array<TypedFunctor<TFunctor, TFunPtr, Dimension(D - 1)>, type_count>::operator[](type_idx);
}
Expand All @@ -92,8 +92,8 @@ struct TypedFunctor<TFunctor, TFunPtr, DIM_1D> : private std::array<TFunPtr, typ
const size_t type_idx = static_cast<size_t>(type) - type_t_first_value;
if (type_idx >= this->size()) {
throw_ov_exception(fmt::format("TypedFunctor[Dimension={}]: Type = {} is not supported by TypedFunctor !!",
DIM_1D,
static_cast<Type_t>(type_idx)));
DIM_1D,
static_cast<Type_t>(type_idx)));
}
return std::array<TFunPtr, type_count>::operator[](type_idx);
}
Expand Down
2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/exp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Exp {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


1 change: 0 additions & 1 deletion modules/nvidia_plugin/src/kernels/gelu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ class GeluTanh {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov

2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/hswish.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class HSwish {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Log {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


5 changes: 4 additions & 1 deletion modules/nvidia_plugin/src/kernels/logical_not.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ namespace kernel {

class LogicalNot {
public:
LogicalNot(Type_t element_type, const eltwise::KernelExecAttrs& kernelExecAttrs, std::size_t payloadRank, std::size_t len);
LogicalNot(Type_t element_type,
const eltwise::KernelExecAttrs& kernelExecAttrs,
std::size_t payloadRank,
std::size_t len);

void operator()(cudaStream_t stream, const bool* src, bool* dst) const;

Expand Down
2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/mish.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Mish {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/sin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Sin {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/sinh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Sinh {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


2 changes: 0 additions & 2 deletions modules/nvidia_plugin/src/kernels/sqrt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Sqrt {
} // namespace kernel
} // namespace nvidia_gpu
} // namespace ov


Loading

0 comments on commit 6ab3bf4

Please sign in to comment.