Skip to content

Commit

Permalink
Review updates.
Browse files Browse the repository at this point in the history
+ Fix some documentation issues.
+ Fix some spacing issues.
+ Do not duplicate `GKO_DECLARE_EXECUTOR_FRIEND` macro.

Co-authored-by: Pratik Nayak <pratikvn@protonmail.com>
Co-authored-by: Thomas Grützmacher <thomas.gruetzmacher@kit.edu>
  • Loading branch information
3 people committed Oct 26, 2020
1 parent 9a522b1 commit f847396
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ option(GINKGO_BUILD_EXAMPLES "Build Ginkgo's examples" ON)
option(GINKGO_BUILD_BENCHMARKS "Build Ginkgo's benchmarks" ON)
option(GINKGO_BUILD_REFERENCE "Compile reference CPU kernels" ON)
option(GINKGO_BUILD_OMP "Compile OpenMP kernels for CPU" ${GINKGO_HAS_OMP})
option(GINKGO_BUILD_DPCPP "Compile DPC++ kernels for CPU" ${GINKGO_HAS_DPCPP})
option(GINKGO_BUILD_DPCPP "Compile DPC++ kernels for Intel GPUs or other DPC++"
"enabled hardware" ${GINKGO_HAS_DPCPP})
option(GINKGO_BUILD_CUDA "Compile kernels for NVIDIA GPUs" ${GINKGO_HAS_CUDA})
option(GINKGO_BUILD_HIP "Compile kernels for AMD or NVIDIA GPUs" ${GINKGO_HAS_HIP})
option(GINKGO_BUILD_DOC "Generate documentation" OFF)
Expand Down
3 changes: 3 additions & 0 deletions core/device_hooks/dpcpp_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

namespace gko {


version version_info::get_dpcpp_version() noexcept
{
// We just return the version with a special "not compiled" tag in
Expand Down Expand Up @@ -85,10 +86,12 @@ void DpcppExecutor::raw_copy_to(const CudaExecutor *, size_type num_bytes,
const void *src_ptr, void *dest_ptr) const
GKO_NOT_COMPILED(dpcpp);


void DpcppExecutor::raw_copy_to(const HipExecutor *, size_type num_bytes,
const void *src_ptr, void *dest_ptr) const
GKO_NOT_COMPILED(dpcpp);


void DpcppExecutor::raw_copy_to(const DpcppExecutor *, size_type num_bytes,
const void *src_ptr, void *dest_ptr) const
GKO_NOT_COMPILED(dpcpp);
Expand Down
11 changes: 11 additions & 0 deletions core/test/base/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ TEST(OmpExecutor, RunsCorrectOperation)
exec_ptr omp = gko::OmpExecutor::create();

omp->run(ExampleOperation(value));

ASSERT_EQ(1, value);
}

Expand All @@ -96,6 +97,7 @@ TEST(OmpExecutor, RunsCorrectLambdaOperation)
exec_ptr omp = gko::OmpExecutor::create();

omp->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda);

ASSERT_EQ(1, value);
}

Expand Down Expand Up @@ -160,6 +162,7 @@ TEST(ReferenceExecutor, RunsCorrectOperation)
exec_ptr ref = gko::ReferenceExecutor::create();

ref->run(ExampleOperation(value));

ASSERT_EQ(5, value);
}

Expand All @@ -174,6 +177,7 @@ TEST(ReferenceExecutor, RunsCorrectLambdaOperation)
exec_ptr ref = gko::ReferenceExecutor::create();

ref->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda);

ASSERT_EQ(1, value);
}

Expand Down Expand Up @@ -285,6 +289,7 @@ TEST(CudaExecutor, RunsCorrectOperation)
gko::CudaExecutor::create(0, gko::OmpExecutor::create(), true);

cuda->run(ExampleOperation(value));

ASSERT_EQ(2, value);
}

Expand All @@ -300,6 +305,7 @@ TEST(CudaExecutor, RunsCorrectLambdaOperation)
gko::CudaExecutor::create(0, gko::OmpExecutor::create(), true);

cuda->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda);

ASSERT_EQ(2, value);
}

Expand Down Expand Up @@ -357,6 +363,7 @@ TEST(HipExecutor, RunsCorrectOperation)
exec_ptr hip = gko::HipExecutor::create(0, gko::OmpExecutor::create());

hip->run(ExampleOperation(value));

ASSERT_EQ(3, value);
}

Expand All @@ -371,6 +378,7 @@ TEST(HipExecutor, RunsCorrectLambdaOperation)
exec_ptr hip = gko::HipExecutor::create(0, gko::OmpExecutor::create());

hip->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda);

ASSERT_EQ(3, value);
}

Expand Down Expand Up @@ -428,6 +436,7 @@ TEST(DpcppExecutor, RunsCorrectOperation)
exec_ptr dpcpp = gko::DpcppExecutor::create(0, gko::OmpExecutor::create());

dpcpp->run(ExampleOperation(value));

ASSERT_EQ(4, value);
}

Expand All @@ -442,6 +451,7 @@ TEST(DpcppExecutor, RunsCorrectLambdaOperation)
exec_ptr dpcpp = gko::DpcppExecutor::create(0, gko::OmpExecutor::create());

dpcpp->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda);

ASSERT_EQ(4, value);
}

Expand Down Expand Up @@ -498,6 +508,7 @@ TEST(ExecutorDeleter, DeletesObject)
TEST(ExecutorDeleter, AvoidsDeletionForNullExecutor)
{
int x[5];

ASSERT_NO_THROW(gko::executor_deleter<int>{nullptr}(x));
}

Expand Down
2 changes: 1 addition & 1 deletion doc/examples/examples.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* <ol>
* <li> <code>-DGINKGO_BUILD_CUDA=ON</code> option for NVIDIA GPUs.
* <li> <code>-DGINKGO_BUILD_HIP=ON</code> option for AMD or NVIDIA GPUs.
* <li> <code>-DGINKGO_BUILD_SYCL=ON</code> option for Intel GPUs (and
* <li> <code>-DGINKGO_BUILD_DPCPP=ON</code> option for Intel GPUs (and
* possibly any other platform).
* </ol
*
Expand Down
11 changes: 3 additions & 8 deletions include/ginkgo/core/base/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ private: \
"semi-colon warnings")


#define GKO_DECLARE_EXECUTOR_FRIEND(_type, ...) friend class _type

/**
* The first step in using the Ginkgo library consists of creating an
* executor. Executors are used to specify the location for the data of linear
Expand Down Expand Up @@ -465,12 +467,8 @@ class Executor : public log::EnableLogging<Executor> {
template <typename T>
friend class detail::ExecutorBase;

#define GKO_DECLARE_EXECUTOR_FRIEND(_type, ...) friend class _type

GKO_ENABLE_FOR_ALL_EXECUTORS(GKO_DECLARE_EXECUTOR_FRIEND);

#undef GKO_DECLARE_EXECUTOR_FRIEND

public:
virtual ~Executor() = default;

Expand Down Expand Up @@ -817,12 +815,8 @@ namespace detail {

template <typename ConcreteExecutor>
class ExecutorBase : public Executor {
#define GKO_DECLARE_EXECUTOR_FRIEND(_type, ...) friend class _type

GKO_ENABLE_FOR_ALL_EXECUTORS(GKO_DECLARE_EXECUTOR_FRIEND);

#undef GKO_DECLARE_EXECUTOR_FRIEND

public:
void run(const Operation &op) const override
{
Expand Down Expand Up @@ -850,6 +844,7 @@ class ExecutorBase : public Executor {
}
};

#undef GKO_DECLARE_EXECUTOR_FRIEND

/**
* Controls whether the DeviceReset function should be called thanks to a
Expand Down

0 comments on commit f847396

Please sign in to comment.