Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outputting to file makes bad text files #39

Closed
hjmallon opened this issue Jul 20, 2017 · 0 comments
Closed

Outputting to file makes bad text files #39

hjmallon opened this issue Jul 20, 2017 · 0 comments

Comments

@hjmallon
Copy link
Contributor

./clpeak > output.txt

This makes bad output files as the functions like "platforms[p].getInfo<CL_PLATFORM_NAME>()" seems to give ['A', 'p', 'p', 'l', 'e', '\0'] rather than ['A', 'p', 'p', 'l', 'e']. If I try to change cl.hpp to cl2.hpp then this problem is fixed. I didn't want to submit a pull request as I have only tested on macOS and it works when building with Xcode but CMAKE_BUILD_TYPE=Debug and building with make returns "Release Object (-34)" adn I haven't got that working yet.

diff --git a/include/clpeak.h b/include/clpeak.h
index 1d4c59f..156dc57 100644
--- a/include/clpeak.h
+++ b/include/clpeak.h
@@ -1,9 +1,10 @@
 #ifndef CLPEAK_HPP
 #define CLPEAK_HPP
 
-#define __CL_ENABLE_EXCEPTIONS
-
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 100
+#define CL_HPP_TARGET_OPENCL_VERSION 100
+#include <CL/cl2.hpp>
 
 #include <iostream>
 #include <stdio.h>
diff --git a/src/clpeak.cpp b/src/clpeak.cpp
index 273447a..e44d085 100644
--- a/src/clpeak.cpp
+++ b/src/clpeak.cpp
@@ -2,7 +2,7 @@
 
 #define MSTRINGIFY(...) #__VA_ARGS__
 
-static const char *stringifiedKernels =
+static const string stringifiedKernels =
     #include "global_bandwidth_kernels.cl"
     #include "compute_sp_kernels.cl"
     #include "compute_hp_kernels.cl"
@@ -10,7 +10,7 @@ static const char *stringifiedKernels =
     #include "compute_integer_kernels.cl"
     ;
 
-static const char *stringifiedKernelsNoInt =
+static const string stringifiedKernelsNoInt =
     #include "global_bandwidth_kernels.cl"
     #include "compute_sp_kernels.cl"
     #include "compute_hp_kernels.cl"
@@ -83,13 +84,13 @@ int clPeak::runAll()
       // Causes Segmentation fault: 11
       if(isIntel || isApple)
       {
-        cl::Program::Sources source(1, make_pair(stringifiedKernelsNoInt, (strlen(stringifiedKernelsNoInt)+1)));
+        cl::Program::Sources source(1, stringifiedKernelsNoInt);
         isComputeInt = false;
         prog = cl::Program(ctx, source);
       }
       else
       {
-        cl::Program::Sources source(1, make_pair(stringifiedKernels, (strlen(stringifiedKernels)+1)));
+        cl::Program::Sources source(1, stringifiedKernels);
         prog = cl::Program(ctx, source);
       }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant