fully operational F16
This commit is contained in:
parent
a6bf3ca572
commit
7bd67a2cb9
4 changed files with 944 additions and 1172 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -5,78 +5,5 @@ import std;
|
|||
using namespace Crafter;
|
||||
|
||||
int main() {
|
||||
// _Float16 test[] {2,1,2, 2,1,2, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
// _Float16 test2[] {2,3,3, 2,5,21, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
// VectorF16L<3,2> vec(test);
|
||||
// VectorF16L<3,2> vec2(test2);
|
||||
// VectorF16L<3,2> result = VectorF16L<3,2>::Cross(vec, vec2);
|
||||
|
||||
|
||||
// Vector<float, 3, 0> test5(2,1,2);
|
||||
// Vector<float, 3, 0> test6(2,3,3);
|
||||
// Vector<float, 3, 0> test3 = Vector<float, 3, 0>::Cross(test5, test6);
|
||||
|
||||
|
||||
|
||||
//VectorF16L<3,2> result = vec + vec2;
|
||||
//std::println("{}\n{}", result, test3);
|
||||
// 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));
|
||||
}
|
||||
20
project.json
20
project.json
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "crafter-match",
|
||||
"name": "crafter-math",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "base",
|
||||
|
|
@ -20,16 +20,24 @@
|
|||
"type":"library",
|
||||
"dependencies": []
|
||||
},
|
||||
{
|
||||
"name": "lib-shared",
|
||||
"extends": ["base"],
|
||||
"type":"shared-library",
|
||||
"dependencies": []
|
||||
},
|
||||
{
|
||||
"name": "lib-debug",
|
||||
"extends": ["lib"],
|
||||
"debug": true
|
||||
},
|
||||
}
|
||||
],
|
||||
"tests":[
|
||||
{
|
||||
"name": "test",
|
||||
"implementations": ["interfaces/main"],
|
||||
"extends": ["base"],
|
||||
"debug": true
|
||||
"name": "F16x86",
|
||||
"implementations": ["tests/VectorF16"],
|
||||
"march": "sapphirerapids",
|
||||
"extends": ["lib-shared"]
|
||||
}
|
||||
]
|
||||
}
|
||||
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