From d8a8d3dce73998fbf864489e0eccbc59159dcbe6 Mon Sep 17 00:00:00 2001
From: trinitas <gydani2@gmail.com>
Date: Mon, 28 Feb 2022 11:29:53 +0100
Subject: [PATCH] Organization + cleanup

---
 Primitives/OpenCLHandler.h             |  2 +-
 Primitives/Primitives.cpp              | 91 +-------------------------
 Primitives/Primitives.vcxproj          |  4 +-
 Primitives/Primitives.vcxproj.filters  |  4 +-
 Primitives/{ => primitives}/Square.cpp |  2 +-
 Primitives/{ => primitives}/Tests.h    |  2 +-
 6 files changed, 8 insertions(+), 97 deletions(-)
 rename Primitives/{ => primitives}/Square.cpp (98%)
 rename Primitives/{ => primitives}/Tests.h (97%)

diff --git a/Primitives/OpenCLHandler.h b/Primitives/OpenCLHandler.h
index 9130b12..ae17222 100644
--- a/Primitives/OpenCLHandler.h
+++ b/Primitives/OpenCLHandler.h
@@ -1,5 +1,5 @@
 #pragma once
-#include "Tests.h"
+#include "primitives/Tests.h"
 
 
 class OpenCLHandler {
diff --git a/Primitives/Primitives.cpp b/Primitives/Primitives.cpp
index 9376d78..8fb99d2 100644
--- a/Primitives/Primitives.cpp
+++ b/Primitives/Primitives.cpp
@@ -5,7 +5,7 @@
 #include <iostream>
 #include "Common.h"
 #include "OpenCLHandler.h"
-#include "Tests.h"
+#include "primitives/Tests.h"
 
 // OpenCL C API
 #include <CL/opencl.h>
@@ -52,98 +52,9 @@
 //	}
 //}
 
-//void cppapi()
-//{
-//	cl_int err = CL_SUCCESS;
-//
-//	// Get a platform ID
-//	std::vector<cl::Platform> platforms;
-//	cl::Platform::get(&platforms);
-//	if (platforms.size() == 0)
-//	{
-//		std::cout << "Unable to find suitable platform." << std::endl;
-//		exit(-1);
-//	}
-//
-//	std::cout << platforms[0].getInfo<CL_PLATFORM_NAME>() << std::endl;
-//
-//	// Create a context
-//	cl_context_properties properties[] =
-//	{ CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0 };
-//	cl::Context context(CL_DEVICE_TYPE_GPU, properties);
-//
-//	// Enumerate the devices
-//	std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
-//	std::cout << devices[0].getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>() << std::endl;
-//
-//	// Create the command queue
-//	cl::Event event;
-//	cl::CommandQueue queue(context, devices[0], 0, &err);
-//
-//	// Create the OpenCL program
-//	std::string programSource = FileToString("../kernels/programs.cl");
-//	cl::Program program = cl::Program(context, programSource);
-//	program.build(devices);
-//	
-//	
-//	// Get the kernel handle
-//	cl::Kernel kernel(program, "histogram_global", &err);
-//	CheckCLError(err);
-//
-//	// Allocate and upload the input data
-//	std::vector<float> hostBuffer;
-//	for (size_t index = 0; index < dataSize; ++index)
-//	{
-//		hostBuffer.push_back(static_cast<float>(index % 32));
-//	}
-//
-//	cl::Buffer clInputBuffer = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(float) * dataSize, NULL, &err);
-//	queue.enqueueWriteBuffer(clInputBuffer, 
-//		true, // Blocking!
-//		0, sizeof(float) * dataSize, hostBuffer.data());
-//
-//	// Allocate the output data
-//	cl::Buffer clResultBuffer = cl::Buffer(context, CL_MEM_WRITE_ONLY, sizeof(float) * 32, NULL, &err);
-//
-//	// Set the kernel parameters	
-//	kernel.setArg(0, clInputBuffer); // kernel FV param�terei sorrendben
-//	kernel.setArg(1, clResultBuffer);
-//
-//	// Enqueue the kernel
-//	queue.enqueueNDRangeKernel(kernel,
-//		cl::NullRange,				// Indexek nem eloffszetelve
-//		cl::NDRange(dataSize, 1),	// Minden elemet egy sz�l
-//		cl::NullRange,				// Workgroup m�ret? - ez az auto, ha nem indul, 1024-re, onnan cs�kkent, amig elindul
-//		NULL,						// 
-//		&event); // � jlezi hogy v�ge, lsd lent
-//
-//	// Create reference values
-//	for (size_t index = 0; index < dataSize; ++index) {
-//	}
-//	event.wait();
-//
-//	// Copy result back to host
-//	queue.enqueueReadBuffer(clResultBuffer, true, 0, sizeof(float) * 32, hostBuffer.data());
-//
-////	Validate the result
-//	for (size_t index = 0; index < 32; ++index)
-//	{
-//		if (hostBuffer[index] != index*index)
-//		{
-//			std::cout << "Wrong result at [" << index << "]: " << hostBuffer[index] << "!=" << index*index << std::endl;
-//			break;
-//		}
-//	}
-//	for (size_t index = 0; index < 32; ++index) {
-//		std::cout << index << ": " << hostBuffer[index] << std::endl;
-//	}
-//	std::cout << "Finished" << std::endl;
-//}
 
 int main()
 {
-	//capi();
-	//cppapi();
 	OpenCLHandler handler;
 	std::vector<TestCase*> tests;
 
diff --git a/Primitives/Primitives.vcxproj b/Primitives/Primitives.vcxproj
index 772e644..2d3e8bd 100644
--- a/Primitives/Primitives.vcxproj
+++ b/Primitives/Primitives.vcxproj
@@ -75,12 +75,12 @@
     <ClCompile Include="Common.cpp" />
     <ClInclude Include="Common.h" />
     <ClInclude Include="OpenCLHandler.h" />
-    <ClInclude Include="Tests.h" />
+    <ClInclude Include="primitives\Tests.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="OpenCLHandler.cpp" />
     <ClCompile Include="Primitives.cpp" />
-    <ClCompile Include="Square.cpp" />
+    <ClCompile Include="primitives\Square.cpp" />
   </ItemGroup>
   <ItemGroup>
     <None Include="..\kernels\programs.cl" />
diff --git a/Primitives/Primitives.vcxproj.filters b/Primitives/Primitives.vcxproj.filters
index ef57a55..7ff3e82 100644
--- a/Primitives/Primitives.vcxproj.filters
+++ b/Primitives/Primitives.vcxproj.filters
@@ -21,7 +21,7 @@
     <ClInclude Include="cl.hpp">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Tests.h">
+    <ClInclude Include="primitives\Tests.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="OpenCLHandler.h">
@@ -35,7 +35,7 @@
     <ClCompile Include="Primitives.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Square.cpp">
+    <ClCompile Include="primitives\Square.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="OpenCLHandler.cpp">
diff --git a/Primitives/Square.cpp b/Primitives/primitives/Square.cpp
similarity index 98%
rename from Primitives/Square.cpp
rename to Primitives/primitives/Square.cpp
index 043ab5a..9361e42 100644
--- a/Primitives/Square.cpp
+++ b/Primitives/primitives/Square.cpp
@@ -1,5 +1,5 @@
 #include <iostream>
-#include "Common.h"
+#include "../Common.h"
 #include "Tests.h"
 
 
diff --git a/Primitives/Tests.h b/Primitives/primitives/Tests.h
similarity index 97%
rename from Primitives/Tests.h
rename to Primitives/primitives/Tests.h
index 65c9b53..2676a14 100644
--- a/Primitives/Tests.h
+++ b/Primitives/primitives/Tests.h
@@ -1,6 +1,6 @@
 #pragma once
 #include <string>
-#include "cl.hpp"
+#include "../cl.hpp"