Initial commit
This commit is contained in:
9
src/CMakeLists.txt
Normal file
9
src/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
add_library(trigdx reference.cpp)
|
||||
|
||||
target_include_directories(trigdx PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
if(USE_MKL)
|
||||
find_package(MKL REQUIRED)
|
||||
target_sources(trigdx PRIVATE mkl.cpp)
|
||||
target_link_libraries(trigdx PRIVATE MKL::MKL)
|
||||
endif()
|
||||
16
src/mkl.cpp
Normal file
16
src/mkl.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <mkl_vml.h>
|
||||
|
||||
#include "trigdx/mkl.hpp"
|
||||
|
||||
void MKLBackend::compute_sinf(size_t n, const float *x, float *s) const {
|
||||
vmsSin(static_cast<MKL_INT>(n), x, s, VML_HA);
|
||||
}
|
||||
|
||||
void MKLBackend::compute_cosf(size_t n, const float *x, float *c) const {
|
||||
vmsCos(static_cast<MKL_INT>(n), x, c, VML_HA);
|
||||
}
|
||||
|
||||
void MKLBackend::compute_sincosf(size_t n, const float *x, float *s,
|
||||
float *c) const {
|
||||
vmsSinCos(static_cast<MKL_INT>(n), x, s, c, VML_HA);
|
||||
}
|
||||
23
src/reference.cpp
Normal file
23
src/reference.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "trigdx/reference.hpp"
|
||||
|
||||
void ReferenceBackend::compute_sinf(size_t n, const float *x, float *s) const {
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
s[i] = std::sinf(x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void ReferenceBackend::compute_cosf(size_t n, const float *x, float *c) const {
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
c[i] = std::cosf(x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void ReferenceBackend::compute_sincosf(size_t n, const float *x, float *s,
|
||||
float *c) const {
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
s[i] = std::sinf(x[i]);
|
||||
c[i] = std::cosf(x[i]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user