Compare commits
2 commits
07910a81c3
...
7bd67a2cb9
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bd67a2cb9 | |||
| a6bf3ca572 |
5 changed files with 526 additions and 801 deletions
|
|
@ -30,10 +30,10 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __AVX512FP16__
|
#ifdef __AVX512FP16__
|
||||||
export template <std::uint32_t Len, std::uint32_t Packing, std::uint32_t Repeats>
|
export template <std::uint32_t Len, std::uint32_t Packing>
|
||||||
using VectorF16L = VectorF16<Len, Packing, Repeats>;
|
using VectorF16L = VectorF16<Len, Packing>;
|
||||||
#else
|
#else
|
||||||
export template <std::uint32_t Len, std::uint32_t Packing, std::uint32_t Repeats>
|
export template <std::uint32_t Len, std::uint32_t Packing>
|
||||||
using VectorF16L = VectorF32<Len, Packing, Repeats>;
|
using VectorF16L = VectorF32<Len, Packing>;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -5,67 +5,5 @@ import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
_Float16 test[] {0,1,2,3,0,1,2,3};
|
|
||||||
VectorF16L<4,1,2> vec(test);
|
|
||||||
VectorF16L<4,1,2> vec2(test);
|
|
||||||
std::println("{}", vec+vec2);
|
|
||||||
// std::random_device rd;
|
|
||||||
// std::mt19937 gen(rd());
|
|
||||||
// std::uniform_real_distribution<float> dist(0, 100);
|
|
||||||
|
|
||||||
// Vector<_Float16, 8, 8> vA;
|
|
||||||
// for(std::uint32_t i = 0; i < 8; i++) {
|
|
||||||
// vA.v[i] = dist(gen);
|
|
||||||
// }
|
|
||||||
// VectorF16<4, 2, 1> vfA(&vA);
|
|
||||||
|
|
||||||
// Vector<_Float16, 16, 16> vB;
|
|
||||||
// for(std::uint32_t i = 0; i < 16; i++) {
|
|
||||||
// vB.v[i] = dist(gen);
|
|
||||||
// }
|
|
||||||
// VectorF16<4, 2, 2> vfB(&vB);
|
|
||||||
|
|
||||||
// VectorF16<4, 2, 1> vfC = vfA + vfB;
|
|
||||||
// auto start = std::chrono::high_resolution_clock::now();
|
|
||||||
// for(std::uint32_t i = 0; i < 90000000; i++) {
|
|
||||||
// vfC = vfC + vfB;
|
|
||||||
// }
|
|
||||||
// auto end = std::chrono::high_resolution_clock::now();
|
|
||||||
// std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end-start) << std::endl;
|
|
||||||
// std::println("{}", vfC);
|
|
||||||
|
|
||||||
// std::random_device rd;
|
|
||||||
// std::mt19937 gen(rd());
|
|
||||||
// std::uniform_real_distribution<float> dist(0, 100);
|
|
||||||
|
|
||||||
// Vector<_Float16, 32, 32> vA;
|
|
||||||
// for(std::uint32_t i = 0; i < 32; i++) {
|
|
||||||
// vA.v[i] = dist(gen);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// std::string log;
|
|
||||||
// std::chrono::duration<double> totalVector(0);
|
|
||||||
// std::tuple<VectorF16<4, 2, 4>, VectorF16<4, 2, 4>, VectorF16<4, 2, 4>, VectorF16<4, 2, 4>> vfA {VectorF16<4, 2, 4>(&vA), VectorF16<4, 2, 4>(&vA), VectorF16<4, 2, 4>(&vA), VectorF16<4, 2, 4>(&vA)};
|
|
||||||
// for(std::uint32_t i = 0; i < 1000000; i++) {
|
|
||||||
// auto start = std::chrono::high_resolution_clock::now();
|
|
||||||
// vfA = VectorF16<4, 2, 4>::Normalize(std::get<0>(vfA), std::get<1>(vfA), std::get<2>(vfA), std::get<3>(vfA));
|
|
||||||
// auto end = std::chrono::high_resolution_clock::now();
|
|
||||||
// totalVector += end-start;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// std::chrono::duration<double> totalScalar(0);
|
|
||||||
// Vector<_Float16, 4, 4> vB;
|
|
||||||
// for(std::uint32_t i = 0; i < 4; i++) {
|
|
||||||
// vB.v[i] = dist(gen);
|
|
||||||
// }
|
|
||||||
// for(std::uint32_t i = 0; i < 1000000; i++) {
|
|
||||||
// auto start2 = std::chrono::high_resolution_clock::now();
|
|
||||||
// vB.Normalize();
|
|
||||||
// auto end2 = std::chrono::high_resolution_clock::now();
|
|
||||||
// totalScalar += end2-start2;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// std::println("{} {} {} {}", std::get<0>(vfA), std::get<1>(vfA), std::get<2>(vfA), std::get<3>(vfA));
|
|
||||||
// std::println("{}", vB);
|
|
||||||
// std::println("Vector: {}, Scalar: {}", std::chrono::duration_cast<std::chrono::milliseconds>(totalVector), std::chrono::duration_cast<std::chrono::milliseconds>(totalScalar*8));
|
|
||||||
}
|
}
|
||||||
21
project.json
21
project.json
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "crafter-match",
|
"name": "crafter-math",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "base",
|
"name": "base",
|
||||||
|
|
@ -20,17 +20,24 @@
|
||||||
"type":"library",
|
"type":"library",
|
||||||
"dependencies": []
|
"dependencies": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "lib-shared",
|
||||||
|
"extends": ["base"],
|
||||||
|
"type":"shared-library",
|
||||||
|
"dependencies": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "lib-debug",
|
"name": "lib-debug",
|
||||||
"extends": ["lib"],
|
"extends": ["lib"],
|
||||||
"debug": true
|
"debug": true
|
||||||
},
|
}
|
||||||
|
],
|
||||||
|
"tests":[
|
||||||
{
|
{
|
||||||
"name": "test",
|
"name": "F16x86",
|
||||||
"implementations": ["interfaces/main"],
|
"implementations": ["tests/VectorF16"],
|
||||||
"extends": ["base"],
|
"march": "sapphirerapids",
|
||||||
"debug": true,
|
"extends": ["lib-shared"]
|
||||||
"march": "raptorlake"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
52
tests/VectorF16.cpp
Normal file
52
tests/VectorF16.cpp
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
Crafter® Build
|
||||||
|
Copyright (C) 2026 Catcrafts®
|
||||||
|
Catcrafts.net
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License version 3.0 as published by the Free Software Foundation;
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
import Crafter.Math;
|
||||||
|
import std;
|
||||||
|
using namespace Crafter;
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
std::string* RunTest() {
|
||||||
|
{
|
||||||
|
_Float16 floats[] {0,1,2,3,4,5,6,7,8};
|
||||||
|
VectorF16<8, 1> vec1(floats);
|
||||||
|
|
||||||
|
Vector<_Float16, 8, VectorF16<8, 1>::Alignment> stored = vec1.Store();
|
||||||
|
for(std::uint8_t i = 0; i < 8; i++) {
|
||||||
|
if(stored.v[i] != floats[i]) {
|
||||||
|
return new std::string("Load Store does not match");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
_Float16 floats[] {0,1,2,3,4,5,6,7,8};
|
||||||
|
VectorF16<8, 1> vec1(floats);
|
||||||
|
VectorF16<8, 1> result = vec1 + vec1;
|
||||||
|
Vector<_Float16, 8, VectorF16<8, 1>::Alignment> stored = result.Store();
|
||||||
|
for(std::uint8_t i = 0; i < 8; i++) {
|
||||||
|
if(stored.v[i] != floats[i] + floats[i]) {
|
||||||
|
return new std::string("Add does not match");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue