Created
April 27, 2024 17:53
-
-
Save tejainece/7f848f28aa048ea03839c94b14473b90 to your computer and use it in GitHub Desktop.
SIMD trials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by tejag on 2024-04-26. | |
// | |
#include <cxxabi.h> | |
#include <experimental/simd> | |
#include <iostream> | |
#include <vector> | |
template <typename T> void printType() { | |
std::cout << abi::__cxa_demangle(typeid(T).name(), NULL, NULL, NULL); | |
} | |
namespace stdx = std::experimental; | |
int main() { | |
using toFloat = stdx::rebind_simd_t<float, stdx::fixed_size_simd<uint8_t, 4>>; | |
std::vector<uint8_t> v = {1, 2, 3, 4}; | |
stdx::fixed_size_simd<uint8_t, 4> a(v.data(), stdx::vector_aligned); | |
auto fs = stdx::simd_cast<toFloat>(a) + 0.5f; | |
std::vector<float> out(4); | |
fs.copy_to(out.data(), stdx::vector_aligned); | |
for (auto i : out) { | |
std::cout << i << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment