virtual-functions

How to implement device side CUDA virtual functions?

ぃ、小莉子 提交于 2021-02-02 08:13:19
问题 I see that CUDA doesn't allow for classes with virtual functions to be passed into kernel functions. Are there any work-arounds to this limitation? I would really like to be able to use polymorphism within a kernel function. Thanks! 回答1: The most important part of Robert Crovella's comment is: The objects simply need to be created on the device. So keeping that in mind, I was dealing with situation where I had an abstract class Function and then some implementations of it encapsulating

Gcc Woverloaded-virtual error on PowerPC ppc64le

↘锁芯ラ 提交于 2021-01-29 14:38:57
问题 I am working on building Istio-envoy on rhel7.6:ppc64le . The build passes, however there are test failures: Error: In file included from test/server/filter_chain_benchmark_test.cc:19:0:` `bazel-out/ppc-fastbuild/bin/external/com_github_google_benchmark/_virtual_includes/benchmark/benchmark/benchmark.h:1071:16: error: 'virtual void benchmark::Fixture::SetUp(benchmark::State&)' was hidden [-Werror=overloaded-virtual]` `virtual void SetUp(State& st) { SetUp(const_cast<const State&>(st)); }` ` ^

What does a non-trivial copy constructor do? [duplicate]

泪湿孤枕 提交于 2021-01-28 03:17:07
问题 This question already has answers here : What is a non-trivial constructor in C++? (3 answers) Closed 5 years ago . In C++, if a copy constructor is not defined the compiler will do that for you. If one is defined, compiler would not. The compiler generated copy constructor can be trivial or non-trivial. In a trivial copy constructor it does a member-wise copy. That's it. However, if there is a virtual function, the copy constructor is non-trivial. It cannot just to bit-wise copy. So here is

Warning: overloaded virtual function “Base::process” is only partially overridden in class “derived”

我的梦境 提交于 2020-08-01 12:53:37
问题 I am getting below warning . part of my code is : class Base { public: virtual void process(int x) {;}; virtual void process(int a,float b) {;}; protected: int pd; float pb; }; class derived: public Base{ public: void process(int a,float b); } void derived::process(int a,float b){ pd=a; pb=b; .... } I am getting below warning : Warning: overloaded virtual function "Base::process" is only partially overridden in class "derived" any way i have made process as virtual function so I am expecting

Warning: overloaded virtual function “Base::process” is only partially overridden in class “derived”

三世轮回 提交于 2020-08-01 12:49:09
问题 I am getting below warning . part of my code is : class Base { public: virtual void process(int x) {;}; virtual void process(int a,float b) {;}; protected: int pd; float pb; }; class derived: public Base{ public: void process(int a,float b); } void derived::process(int a,float b){ pd=a; pb=b; .... } I am getting below warning : Warning: overloaded virtual function "Base::process" is only partially overridden in class "derived" any way i have made process as virtual function so I am expecting

Can I override a CUDA host-and-device function with a host-only function?

蓝咒 提交于 2020-02-05 02:36:12
问题 Consider the following program: class A { __host__ __device__ void foo(); }; class B : A { __host__ void foo(); }; int main() { A a; (void) a; B b; (void) b; } This compiles (GodBolt) with nvcc 10. Yet, in more complex programs, I sometimes get the following error (line breaks for readability): whatever.hpp(88): error: execution space mismatch: overridden entity (function "C::foo") is a __host__ __device__ function, but overriding entity (function "D::foo") is a __host__ function So, nvcc is

override virtual method with template method [duplicate]

痞子三分冷 提交于 2020-02-03 04:43:05
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Can a member function template be virtual? In a base class, the function my_func is defined as virtual. However, in the derived class I would like to have my_func to be a template method. Is this possible? It seems it isn't. I get the error "cannot allocate an object of abstract type" , which I believe it is related to the fact that the compiler does not acknowledge the override of the virtual my_func in the