Skip to content

[SYCL] Add intelfpga vendor header files #511

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

Merged
merged 1 commit into from
Aug 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions sycl/doc/extensions/intel_fpga/fpga_reg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# FPGA reg

Intel FPGA extension fpga_reg() is implemented in header file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fpga_reg() → fpga_reg()

`#include <CL/sycl/intel/fpga_extensions.hpp>`.

fpga_reg is used to help compiler infer that at least one register is on the corresponding data path.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fpga_reg() → fpga_reg()


## Implementation

The implementation is a wrapper class to map fpga_reg function call to built-in \_\_builtin_intel_fpga_reg()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fpga_reg → fpga_reg()
__builtin_intel_fpga_reg() → __builtin_intel_fpga_reg()

only when parsing for SYCL device code.
```c++
#if defined(__clang__) && __has_builtin(__builtin_intel_fpga_reg)
return __builtin_intel_fpga_reg(t);
#else
return t;
#endif

```


## Usage

```c++
#include <CL/sycl/intel/fpga_extensions.hpp>
...
// force at least one register on data path
int a = cl::sycl::intel::fpga_reg(a[k]) + b[k];

...
```
27 changes: 27 additions & 0 deletions sycl/doc/extensions/intel_fpga/fpga_selector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# FPGA selector

Intel FPGA users can use header file: `#include<CL/sycl/intel/fpga_device_selector.hpp>` to simplify their code
when they want to specify FPGA hardware device or FPGA emulation device.

## Implementation

Current implementation is based on platform name. This is useful in the most common case when user have
one FPGA board installed in their system (one device per platform).

## Usage: select FPGA hardware device
```c++
#include <CL/sycl/intel/fpga_device_selector.hpp>
...
// force FPGA hardware device
cl::sycl::queue deviceQueue(cl::sycl::intel::fpga_selector{});
...
```

## Usage: select FPGA emulator device
```c++
#include <CL/sycl/intel/fpga_device_selector.hpp>
...
// force FPGA emulation device
cl::sycl::queue deviceQueue(cl::sycl::intel::fpga_emulator_selector{});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are using {}, replace the outer parenthesis too.

...
```
51 changes: 51 additions & 0 deletions sycl/include/CL/sycl/intel/fpga_device_selector.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//==- fpga_device_selector.hpp --- SYCL FPGA device selector shortcut -----==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

#include <CL/sycl.hpp>

namespace cl {
namespace sycl {
namespace intel {

class platform_selector : public default_selector {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this derive from device_selector instead of default_selector?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. I will fix this in next patch.

private:
std::string device_platform_name;

public:
platform_selector(const std::string &platform_name)
: device_platform_name(platform_name){}

virtual int operator()(const device &device) const {
const platform &pf = device.get_platform();
const std::string &platform_name = pf.get_info<info::platform::name>();
if (platform_name == device_platform_name) {
return 10000;
}
return -1;
}
};

const std::string EMULATION_PLATFORM_NAME =
"Intel(R) FPGA Emulation Platform for OpenCL(TM)";
const std::string HARDWARE_PLATFORM_NAME = "Intel(R) FPGA SDK for OpenCL(TM)";

class fpga_selector : public platform_selector {
public:
fpga_selector() : platform_selector(HARDWARE_PLATFORM_NAME){}
};

class fpga_emulator_selector : public platform_selector {
public:
fpga_emulator_selector() : platform_selector(EMULATION_PLATFORM_NAME){}
};

} // namespace intel
} // namespace sycl
} // namespace cl
11 changes: 11 additions & 0 deletions sycl/include/CL/sycl/intel/fpga_extensions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//==----------- fpga_extensions.hpp --- SYCL FPGA Extensions ---------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once
#include <CL/sycl/intel/fpga_device_selector.hpp>
#include <CL/sycl/intel/fpga_reg.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing EOL.

25 changes: 25 additions & 0 deletions sycl/include/CL/sycl/intel/fpga_reg.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//==-------------- fpga_reg.hpp --- SYCL FPGA Reg Extensions ---------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

namespace cl {
namespace sycl {
namespace intel {

template <typename T> T fpga_reg(const T &t) {
#if defined(__clang__) && __has_builtin(__builtin_intel_fpga_reg)
return __builtin_intel_fpga_reg(t);
#else
return t;
#endif
}

} // namespace intel
} // namespace sycl
} // namespace cl