Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2018-02-08 00:24:08 +0300
committerHieu Hoang <hieuhoang@gmail.com>2018-02-08 00:24:08 +0300
commitacb66d82dc93422e6d128ec3b7c09f31f489a36f (patch)
tree79c84e81e8d2328cd856f0653389ab14353b63b3
parent9c88566af4835e6a2603e510f81b87c888d05cb5 (diff)
delete fpga
-rw-r--r--contrib/fpga/kernel.h73
-rw-r--r--contrib/fpga/main.cpp50
-rw-r--r--contrib/fpga/matrix.h61
-rw-r--r--contrib/fpga/types-fpga.h34
4 files changed, 0 insertions, 218 deletions
diff --git a/contrib/fpga/kernel.h b/contrib/fpga/kernel.h
deleted file mode 100644
index f0d2aae6..00000000
--- a/contrib/fpga/kernel.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-#include <string>
-#include "types-fpga.h"
-
-cl_context CreateContext(
- size_t maxDevices,
- cl_device_id *devices,
- cl_uint &numDevices);
-
-cl_kernel CreateKernel(const std::string &filePath, const std::string &kernelName, const OpenCLInfo &openCLInfo);
-cl_command_queue CreateCommandQueue(const OpenCLInfo &openCLInfo);
-
-/////////////////////////////////////////////////////////////////////////////////////
-template <typename T>
-void SetKernelArg(cl_kernel kernel, cl_uint argNum, const T &t)
-{
- //std::cerr << "arg" << argNum << "=" << t << std::endl ;
- CheckError( clSetKernelArg(kernel, argNum, sizeof(T), &t) );
-}
-
-template<typename T, typename... Args>
-void SetKernelArg(cl_kernel kernel, cl_uint argNum, const T &t, Args... args) // recursive variadic function
-{
- //std::cerr << "arg" << argNum << "=" << t << std::endl ;
- CheckError( clSetKernelArg(kernel, argNum, sizeof(T), &t) );
-
- SetKernelArg(kernel, argNum + 1, args...) ;
-}
-
-template<typename... Args>
-void CallOpenCL(
- const std::string &filePath,
- const std::string &kernelName,
- const OpenCLInfo &openCLInfo,
- Args... args
- )
-{
- cl_int err;
- size_t global; // global domain size for our calculation
- size_t local; // local domain size for our calculation
-
- cl_mem output = clCreateBuffer(openCLInfo.context, CL_MEM_WRITE_ONLY, sizeof(size_t), NULL, &err);
- CheckError(err);
- assert(output);
-
- // create kernel
- cl_kernel kernel = CreateKernel(filePath, kernelName, openCLInfo);
-
- // Set the arguments to our compute kernel
- SetKernelArg(kernel, 0, args...);
-
- // Get the maximum work group size for executing the kernel on the device
- //
- CheckError( clGetKernelWorkGroupInfo(kernel, openCLInfo.device, CL_KERNEL_WORK_GROUP_SIZE, sizeof(local), &local, NULL) );
-
- //global = 1024;
- local = 1;
- global = 1;
-
- //cerr << "local=" << local << endl;
- //cerr << "global=" << global << endl;
-
- CheckError( clEnqueueNDRangeKernel(openCLInfo.commands, kernel, 1, NULL, &global, &local, 0, NULL, NULL) );
-
- // Wait for the command commands to get serviced before reading back results
- //
- CheckError( clFinish(openCLInfo.commands) );
-
-}
-
-/////////////////////////////////////////////////////////////////////////////////////
-
-
diff --git a/contrib/fpga/main.cpp b/contrib/fpga/main.cpp
deleted file mode 100644
index f66e2abd..00000000
--- a/contrib/fpga/main.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <iostream>
-#include <cassert>
-#include <cstdio>
-#include <cstdlib>
-#include <vector>
-#include "types-fpga.h"
-#include "kernel.h"
-#include "matrix.h"
-
-using namespace std;
-
-
-int main()
-{
- cerr << "Starting..." << endl;
-
- OpenCLInfo openCLInfo;
-
- openCLInfo.context = CreateContext(100, openCLInfo.devices, openCLInfo.numDevices);
- cerr << "CreateContext done" << endl;
-
- openCLInfo.device = openCLInfo.devices[0];
- openCLInfo.commands = CreateCommandQueue(openCLInfo);
- cerr << "CreateCommandQueue done" << endl;
-
- cl_kernel kernel = CreateKernel("kernels/OutputLayer.cl", "OutputLayer_float", openCLInfo);
- cerr << "CreateKernel done" << endl;
-
- Matrix<float> W(openCLInfo, true, 85000, 512);
- Matrix<float> X(openCLInfo, true, 512, 640);
- Matrix<float> B(openCLInfo, true, 1, 85000);
- Matrix<float> Y(openCLInfo, true, 85000, 640);
-
- vector<float> vec;
-
- vec.resize(W.size(), 3.3);
- W.Set(vec.data(), vec.size());
-
- vec.resize(X.size(), 21.2);
- X.Set(vec.data(), vec.size());
-
- vec.resize(B.size(), 9.3443);
- B.Set(vec.data(), vec.size());
-
- CallOpenCL("kernels/matrix_functions.cl", "sum_float", openCLInfo,
- X.data(), Y.data(), X.size());
-
- cerr << "Finished" << endl;
-}
-
diff --git a/contrib/fpga/matrix.h b/contrib/fpga/matrix.h
deleted file mode 100644
index 7aac294d..00000000
--- a/contrib/fpga/matrix.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#pragma once
-#include <cassert>
-#include "types-fpga.h"
-
-template<typename T>
-class Matrix
-{
-public:
- Matrix(const OpenCLInfo &openCLInfo, bool rowMajor, unsigned a, unsigned b)
- :openCLInfo_(openCLInfo)
- {
- rowMajor_ = rowMajor;
- dim_[0] = a;
- dim_[1] = b;
- size_ = a * b;
-
- cl_int err;
- mem_ = clCreateBuffer(openCLInfo.context, CL_MEM_READ_WRITE, sizeof(T) * size(), NULL, &err);
- CheckError(err);
- }
-
- cl_mem &data()
- { return mem_; }
-
- const cl_mem &data() const
- { return mem_; }
-
- bool isRowMajor() const
- { return rowMajor_; }
-
- unsigned dim(unsigned i) const
- { return dim_[i]; }
-
- unsigned size() const
- { return size_; }
-
- void Set(const T *arr, size_t count)
- {
- assert(count <= size_);
- size_t bytes = count * sizeof(T);
- CheckError( clEnqueueWriteBuffer(
- openCLInfo_.commands,
- mem_,
- CL_TRUE,
- 0,
- bytes,
- arr,
- 0,
- NULL,
- NULL) );
- CheckError( clFinish(openCLInfo_.commands) );
- }
-
-protected:
- const OpenCLInfo &openCLInfo_;
- bool rowMajor_;
- unsigned dim_[2];
- unsigned size_;
- cl_mem mem_;
-};
-
diff --git a/contrib/fpga/types-fpga.h b/contrib/fpga/types-fpga.h
deleted file mode 100644
index 55d43a8a..00000000
--- a/contrib/fpga/types-fpga.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-#include <iostream>
-#include <cstdio>
-#include <cstdlib>
-
-#ifdef __APPLE__
- #include <OpenCL/opencl.h>
-#else
- #include <CL/cl.h>
-#endif
-
-inline void CheckError(cl_int error)
- {
- if (error != CL_SUCCESS) {
- std::cerr << "OpenCL call failed with error " << error << std::endl;
- std::exit (1);
- }
- }
-
-inline void pfn_notify(const char *errinfo, const void *private_info, size_t cb, void *user_data)
-{
- fprintf(stderr, "OpenCL Error (via pfn_notify): %s\n", errinfo);
-}
-
-struct OpenCLInfo
-{
- cl_context context;
- cl_uint numDevices;
- cl_device_id devices[100];
- cl_device_id device;
- cl_command_queue commands;
-};
-
-