Skip to content

Commit

Permalink
Merge pull request #1 from cppfastio/master
Browse files Browse the repository at this point in the history
dsal
  • Loading branch information
havedifficultyinfindingnames committed Jul 25, 2022
2 parents 9ec73f5 + ecb4c95 commit 85b3eed
Show file tree
Hide file tree
Showing 13 changed files with 793 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<fast_io.h>
#include<fast_io_driver/timer.h>
#include<fast_io_dsal/vector.h>

int main()
{
fast_io::timer t(u8"fast_io::vector");
fast_io::vector<std::size_t> vec(100000000);
}
9 changes: 9 additions & 0 deletions benchmark/0011.containers/vector/0000.initialization/std.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<fast_io.h>
#include<fast_io_driver/timer.h>
#include<vector>

int main()
{
fast_io::timer t(u8"std::vector");
std::vector<std::size_t> vec(100000000);
}
15 changes: 15 additions & 0 deletions benchmark/0011.containers/vector/0001.push_back/fast_io.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<fast_io.h>
#include<fast_io_driver/timer.h>
#include<fast_io_dsal/vector.h>

int main()
{
fast_io::timer tm(u8"fast_io::vector::push_back");
fast_io::vector<std::size_t> vec;
constexpr std::size_t n{100000000};
vec.reserve(n);
for(std::size_t i{};i!=n;++i)
{
vec.emplace_back(i);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<fast_io.h>
#include<fast_io_driver/timer.h>
#include<fast_io_dsal/vector.h>

int main()
{
fast_io::timer tm(u8"fast_io::vector::push_back_unchecked");
fast_io::vector<std::size_t> vec;
constexpr std::size_t n{100000000};
vec.reserve(n);
for(std::size_t i{};i!=n;++i)
{
vec.push_back_unchecked(i);
}
}
15 changes: 15 additions & 0 deletions benchmark/0011.containers/vector/0001.push_back/std.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<fast_io.h>
#include<fast_io_driver/timer.h>
#include<vector>

int main()
{
fast_io::timer tm(u8"std::vector::push_back");
std::vector<std::size_t> vec;
constexpr std::size_t n{100000000};
vec.reserve(n);
for(std::size_t i{};i!=n;++i)
{
vec.push_back(i);
}
}
92 changes: 92 additions & 0 deletions benchmark/0011.containers/vector/0002.multi_push_back/vector.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include<fast_io.h>
#include<fast_io_driver/timer.h>
#if defined(USE_STD)
#include<vector>
#include<cstdint>
namespace test
{
template<typename T>
using vector = ::std::vector<T>;
}
#else
#include<fast_io_dsal/vector.h>

namespace test
{
template<typename T>
using vector = ::fast_io::vector<T>;
}
#endif


/*
Unfortunately fast_io internally sometimes uses vector despite i try to avoid them. Well then better expose the APIs
*/

int main()
{
fast_io::timer t(
#if defined(USE_STD)
u8"std::vectors"
#else
u8"fast_io::vectors"
#endif
);
test::vector<std::int_least32_t> vec1;
test::vector<char32_t> vec2;
test::vector<double> vec3;
test::vector<float> vec4;
test::vector<char> vec5;
test::vector<unsigned char> vec6;
for(std::size_t i{};i!=10000000;++i)
{
vec1.push_back(42);
vec2.push_back(42);
vec3.push_back(43);
vec4.push_back(43);
vec5.push_back(43);
vec6.push_back(43);
vec1.push_back(42);
vec2.push_back(42);
vec3.push_back(43);
vec4.push_back(43);
vec5.push_back(43);
vec6.push_back(43);
vec1.push_back(42);
vec2.push_back(42);
vec3.push_back(43);
vec4.push_back(43);
vec5.push_back(43);
vec6.push_back(43);
vec1.push_back(42);
vec2.push_back(42);
vec3.push_back(43);
vec4.push_back(43);
vec5.push_back(43);
vec6.push_back(43);
vec1.push_back(42);
vec2.push_back(42);
vec3.push_back(43);
vec4.push_back(43);
vec5.push_back(43);
vec6.push_back(43);
vec1.push_back(42);
vec2.push_back(42);
vec3.push_back(43);
vec4.push_back(43);
vec5.push_back(43);
vec6.push_back(43);
vec1.push_back(42);
vec2.push_back(42);
vec3.push_back(43);
vec4.push_back(43);
vec5.push_back(43);
vec6.push_back(43);
vec1.push_back(42);
vec2.push_back(42);
vec3.push_back(43);
vec4.push_back(43);
vec5.push_back(44);
vec6.push_back(44);
}
}
35 changes: 35 additions & 0 deletions examples/0029.containers/vector.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#if defined(USE_STD)
#include<vector>
#include<cstdint>
namespace test
{
template<typename T>
using vector = ::std::vector<T>;
}
#else
#include<fast_io_dsal/vector.h>

namespace test
{
template<typename T>
using vector = ::fast_io::vector<T>;
}
#endif

/*
Unfortunately fast_io internally sometimes uses vector despite i try to avoid them. Well then better expose the APIs
*/

int main()
{
test::vector<std::int_least32_t> vec1;
test::vector<char32_t> vec2;
vec1.push_back(42);
vec2.push_back(42);
vec1.push_back(42);
vec2.push_back(42);
vec1.push_back(42);
vec2.push_back(42);
vec1.push_back(42);
vec2.push_back(42);
}
30 changes: 30 additions & 0 deletions examples/0029.containers/vectorvector.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#if defined(USE_STD)
#include<vector>
#include<cstdint>
namespace test
{
template<typename T>
using vector = ::std::vector<T>;
}
#else
#include<fast_io_dsal/vector.h>

namespace test
{
template<typename T>
using vector = ::fast_io::vector<T>;
}
#endif

/*
Unfortunately fast_io internally sometimes uses vector despite i try to avoid them. Well then better expose the APIs
*/

int main()
{
test::vector<test::vector<std::int_least32_t>> vec1;
test::vector<test::vector<char32_t>> vec2;
vec1.emplace_back();
vec1.emplace_back();
vec1.emplace_back();
}
18 changes: 18 additions & 0 deletions include/fast_io_core_impl/freestanding/relocatable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

namespace fast_io::freestanding
{

template<typename T>
struct is_trivially_relocatable
{
inline static constexpr bool value =
#if defined(__clang__) && defined(__has_extension) && __has_cpp_attribute(clang::trivial_abi)
__is_trivially_relocatable(T) ||
#endif
::std::is_trivially_copyable_v<T>;
};

template<typename T>
inline constexpr bool is_trivially_relocatable_v = is_trivially_relocatable<T>::value;
}
8 changes: 3 additions & 5 deletions include/fast_io_core_impl/terminate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#if (!defined(__GNUC__)&&!defined(__clang__)||defined(__INTEL_COMPILER))
#include<intrin.h>
#if defined(_MSC_VER)&&!defined(__clang__)
#include<cstdlib>
#endif

namespace fast_io
Expand All @@ -18,11 +18,9 @@ namespace fast_io
#else
std::abort();
#endif
#elif defined(_MSC_VER)
__fastfail(1);
#else
std::abort();
#endif
}

}
}
Loading

0 comments on commit 85b3eed

Please sign in to comment.