Add GPUBackend
This commit is contained in:
23
include/trigdx/gpu.hpp
Normal file
23
include/trigdx/gpu.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
#include "interface.hpp"
|
||||
|
||||
class GPUBackend : public Backend {
|
||||
public:
|
||||
GPUBackend();
|
||||
~GPUBackend() override;
|
||||
|
||||
void init(size_t n = 0) override;
|
||||
void compute_sinf(size_t n, const float *x, float *s) const override;
|
||||
void compute_cosf(size_t n, const float *x, float *c) const override;
|
||||
void compute_sincosf(size_t n, const float *x, float *s,
|
||||
float *c) const override;
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
@@ -8,7 +8,7 @@ public:
|
||||
virtual ~Backend() = default;
|
||||
|
||||
// Optional initialization
|
||||
virtual void init() {}
|
||||
virtual void init(size_t n = 0) {}
|
||||
|
||||
// Compute sine for n elements
|
||||
virtual void compute_sinf(size_t n, const float *x, float *s) const = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
LookupBackend();
|
||||
~LookupBackend() override;
|
||||
|
||||
void init() override;
|
||||
void init(size_t n = 0) override;
|
||||
void compute_sinf(size_t n, const float *x, float *s) const override;
|
||||
void compute_cosf(size_t n, const float *x, float *c) const override;
|
||||
void compute_sincosf(size_t n, const float *x, float *s,
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
LookupAVXBackend();
|
||||
~LookupAVXBackend() override;
|
||||
|
||||
void init() override;
|
||||
void init(size_t n = 0) override;
|
||||
void compute_sinf(std::size_t n, const float *x, float *s) const override;
|
||||
void compute_cosf(std::size_t n, const float *x, float *c) const override;
|
||||
void compute_sincosf(std::size_t n, const float *x, float *s,
|
||||
|
||||
Reference in New Issue
Block a user