From 8f51a89375ce5535763cca136326d8d496fcb86e Mon Sep 17 00:00:00 2001 From: gyulaid Date: Wed, 23 Mar 2022 18:34:10 +0100 Subject: [PATCH] Fix https://git.gyulai.cloud/gyulaid/gpgpu/issues/9 --- Common/Tests.h | 73 ------------------------- Primitives.sln | 10 ++++ Primitives/Compact.cpp | 2 +- Primitives/ExclusiveScan.cpp | 2 +- Primitives/Histogram.cpp | 2 +- Primitives/PrimitiveTests.h | 76 +++++++++++++++++++++++++++ Primitives/Primitives.cpp | 2 +- Primitives/Primitives.vcxproj | 3 ++ Primitives/Primitives.vcxproj.filters | 5 ++ Primitives/ReduceAdd.cpp | 2 +- Primitives/Square.cpp | 2 +- 11 files changed, 100 insertions(+), 79 deletions(-) create mode 100644 Primitives/PrimitiveTests.h diff --git a/Common/Tests.h b/Common/Tests.h index 88fec6d..5094914 100644 --- a/Common/Tests.h +++ b/Common/Tests.h @@ -20,76 +20,3 @@ public: virtual std::string description() = 0; }; -class Square : public TestCase { -private: - std::vector gpuResult; - std::vector sourceData; - std::vector cpuResult; -public: - Square(); - void collect_results(cl::CommandQueue* queue); - void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); - void cpu_compute(); - bool validate_results(); - std::string description(); -}; - -class Histogram : public TestCase { -private: - bool global; - size_t valueSet; - std::vector gpuResult; - std::vector sourceData; - std::vector cpuResult; -public: - Histogram(bool _global, int _valueSet, int _data_size); - void collect_results(cl::CommandQueue* queue); - void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); - void cpu_compute(); - bool validate_results(); - std::string description(); -}; - -class ReduceAdd : public TestCase { -private: - std::vector gpuResult; - std::vector sourceData; - float cpuResult; -public: - ReduceAdd(size_t max_size); - void collect_results(cl::CommandQueue* queue); - void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); - void cpu_compute(); - bool validate_results(); - std::string description(); -}; - -class ExclusiveScan : public TestCase { -private: - std::vector gpuResult; - std::vector sourceData; - std::vector cpuResult; -public: - ExclusiveScan(size_t max_size); - void collect_results(cl::CommandQueue* queue); - void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); - void cpu_compute(); - bool validate_results(); - std::string description(); -}; - -class Compact : public TestCase { -private: - std::vector gpuResult; - std::vector sourceData; - std::vector cpuResult; - int limit; - int result_size; -public: - Compact(size_t _data_size); - void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); - void cpu_compute(); - void collect_results(cl::CommandQueue* queue); - bool validate_results(); - std::string description(); -}; \ No newline at end of file diff --git a/Primitives.sln b/Primitives.sln index 103e15d..e0a0b6c 100644 --- a/Primitives.sln +++ b/Primitives.sln @@ -15,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Linear", "Linear\Linear.vcx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "Common\Common.vcxproj", "{F66311CB-C60D-43DE-890C-7E6D8179CA44}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MonteCarlo", "MonteCarlo\MonteCarlo.vcxproj", "{4B53AC9F-C842-4E17-93EB-1362CFD08104}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -47,6 +49,14 @@ Global {F66311CB-C60D-43DE-890C-7E6D8179CA44}.Release|Win32.Build.0 = Release|Win32 {F66311CB-C60D-43DE-890C-7E6D8179CA44}.Release|x64.ActiveCfg = Release|x64 {F66311CB-C60D-43DE-890C-7E6D8179CA44}.Release|x64.Build.0 = Release|x64 + {4B53AC9F-C842-4E17-93EB-1362CFD08104}.Debug|Win32.ActiveCfg = Debug|Win32 + {4B53AC9F-C842-4E17-93EB-1362CFD08104}.Debug|Win32.Build.0 = Debug|Win32 + {4B53AC9F-C842-4E17-93EB-1362CFD08104}.Debug|x64.ActiveCfg = Debug|Win32 + {4B53AC9F-C842-4E17-93EB-1362CFD08104}.Debug|x64.Build.0 = Debug|Win32 + {4B53AC9F-C842-4E17-93EB-1362CFD08104}.Release|Win32.ActiveCfg = Release|Win32 + {4B53AC9F-C842-4E17-93EB-1362CFD08104}.Release|Win32.Build.0 = Release|Win32 + {4B53AC9F-C842-4E17-93EB-1362CFD08104}.Release|x64.ActiveCfg = Release|Win32 + {4B53AC9F-C842-4E17-93EB-1362CFD08104}.Release|x64.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Primitives/Compact.cpp b/Primitives/Compact.cpp index c94008e..4f1e76d 100644 --- a/Primitives/Compact.cpp +++ b/Primitives/Compact.cpp @@ -1,6 +1,6 @@ #include #include "Common.h" -#include "Tests.h" +#include "PrimitiveTests.h" #include Compact::Compact(size_t _data_size) diff --git a/Primitives/ExclusiveScan.cpp b/Primitives/ExclusiveScan.cpp index b6f83e9..a994779 100644 --- a/Primitives/ExclusiveScan.cpp +++ b/Primitives/ExclusiveScan.cpp @@ -1,6 +1,6 @@ #include #include "Common.h" -#include "Tests.h" +#include "PrimitiveTests.h" #include ExclusiveScan::ExclusiveScan(size_t max_size) diff --git a/Primitives/Histogram.cpp b/Primitives/Histogram.cpp index b3d83bc..be8e5c7 100644 --- a/Primitives/Histogram.cpp +++ b/Primitives/Histogram.cpp @@ -1,6 +1,6 @@ #include #include "Common.h" -#include "Tests.h" +#include "PrimitiveTests.h" #include Histogram::Histogram(bool _global, int _valueSet, int _data_size) diff --git a/Primitives/PrimitiveTests.h b/Primitives/PrimitiveTests.h new file mode 100644 index 0000000..e43e437 --- /dev/null +++ b/Primitives/PrimitiveTests.h @@ -0,0 +1,76 @@ +#pragma once +#include "Tests.h" + +class Square : public TestCase { +private: + std::vector gpuResult; + std::vector sourceData; + std::vector cpuResult; +public: + Square(); + void collect_results(cl::CommandQueue* queue); + void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); + void cpu_compute(); + bool validate_results(); + std::string description(); +}; + +class Histogram : public TestCase { +private: + bool global; + size_t valueSet; + std::vector gpuResult; + std::vector sourceData; + std::vector cpuResult; +public: + Histogram(bool _global, int _valueSet, int _data_size); + void collect_results(cl::CommandQueue* queue); + void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); + void cpu_compute(); + bool validate_results(); + std::string description(); +}; + +class ReduceAdd : public TestCase { +private: + std::vector gpuResult; + std::vector sourceData; + float cpuResult; +public: + ReduceAdd(size_t max_size); + void collect_results(cl::CommandQueue* queue); + void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); + void cpu_compute(); + bool validate_results(); + std::string description(); +}; + +class ExclusiveScan : public TestCase { +private: + std::vector gpuResult; + std::vector sourceData; + std::vector cpuResult; +public: + ExclusiveScan(size_t max_size); + void collect_results(cl::CommandQueue* queue); + void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); + void cpu_compute(); + bool validate_results(); + std::string description(); +}; + +class Compact : public TestCase { +private: + std::vector gpuResult; + std::vector sourceData; + std::vector cpuResult; + int limit; + int result_size; +public: + Compact(size_t _data_size); + void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event); + void cpu_compute(); + void collect_results(cl::CommandQueue* queue); + bool validate_results(); + std::string description(); +}; diff --git a/Primitives/Primitives.cpp b/Primitives/Primitives.cpp index b552133..633bfd0 100644 --- a/Primitives/Primitives.cpp +++ b/Primitives/Primitives.cpp @@ -5,7 +5,7 @@ #include #include "Common.h" #include "OpenCLHandler.h" -#include "Tests.h" +#include "PrimitiveTests.h" // OpenCL C API #include diff --git a/Primitives/Primitives.vcxproj b/Primitives/Primitives.vcxproj index b737975..9a0f9ca 100644 --- a/Primitives/Primitives.vcxproj +++ b/Primitives/Primitives.vcxproj @@ -86,6 +86,9 @@ {f66311cb-c60d-43de-890c-7e6d8179ca44} + + + diff --git a/Primitives/Primitives.vcxproj.filters b/Primitives/Primitives.vcxproj.filters index 0fe96df..115ca3e 100644 --- a/Primitives/Primitives.vcxproj.filters +++ b/Primitives/Primitives.vcxproj.filters @@ -42,4 +42,9 @@ Kernels + + + Header Files + + \ No newline at end of file diff --git a/Primitives/ReduceAdd.cpp b/Primitives/ReduceAdd.cpp index c9ff462..932494f 100644 --- a/Primitives/ReduceAdd.cpp +++ b/Primitives/ReduceAdd.cpp @@ -1,7 +1,7 @@ #include #include #include "Common.h" -#include "Tests.h" +#include "PrimitiveTests.h" #include #include diff --git a/Primitives/Square.cpp b/Primitives/Square.cpp index ccf923d..2b0bfe6 100644 --- a/Primitives/Square.cpp +++ b/Primitives/Square.cpp @@ -1,6 +1,6 @@ #include #include "Common.h" -#include "Tests.h" +#include "PrimitiveTests.h" #include