uint8_t HIDDEN_VARIABLE = 0;
FILE* RANDOM_FILE;
+#define GPU_ENABLED
+uint8_t USE_GPU = 0;
+#ifdef GPU_ENABLED
+#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
+#define CL_TARGET_OPENCL_VERSION 120
+#include <CL/cl.h>
+cl_platform_id GPU_platform_id;
+cl_device_id GPU_device_id;
+cl_context GPU_context;
+#endif
+
typedef struct
{
char n[128];
free(lineIDs);
}
+#ifdef GPU_ENABLED
+uint8_t GPU_init()
+{
+ cl_uint count;
+ cl_int err;
+
+ err = clGetPlatformIDs(1, &GPU_platform_id, &count);
+ if (err != CL_SUCCESS || count == 0)
+ {
+ if (err == 0)
+ fprintf(stderr, "GPU disabled: No supported platforms found.\n");
+ else
+ fprintf(stderr, "GPU disabled: clGetPlatformIDs() failed.\n");
+ return 0;
+ }
+
+ err = clGetDeviceIDs(GPU_platform_id, CL_DEVICE_TYPE_GPU, 1, &GPU_device_id, &count);
+ if (err != CL_SUCCESS || count == 0)
+ {
+ if (count == 0)
+ fprintf(stderr, "GPU disabled: No supported GPUs found.\n");
+ else
+ fprintf(stderr, "GPU disabled: clGetDeviceIDs() failed.\n");
+ return 0;
+ }
+
+ GPU_context = clCreateContext(NULL, 1, &GPU_device_id, NULL, NULL, &err);
+ if (err != CL_SUCCESS)
+ {
+ fprintf(stderr, "GPU disabled: clCreateContext() failed.\n");
+ return 0;
+ }
+
+ return 1;
+}
+#endif
+
void main(int argc, char** argv)
{
+ #ifdef GPU_ENABLED
+ USE_GPU = GPU_init();
+ #endif
+
RANDOM_FILE = fopen("/dev/TrueRNG0", "r");
if (!RANDOM_FILE) RANDOM_FILE = fopen("/dev/random", "r");
process(argc, argv);
--- /dev/null
+__kernel g_mmul(__global double* A, __global double* B, __global double* C, const unsigned int N, const unsigned int W)
+{
+ int row = get_global_id(0);
+ int col = get_global_id(1);
+ double sum = 0;
+ for (int i = 0; i < N; i++)
+ {
+ sum += A[row * W + i] * B[i * W + col];
+ }
+ C[row * W + col] = sum;
+}
\ No newline at end of file