Browse Source

update: fix compile errors

legacy
Dnomd343 1 month ago
parent
commit
e9d7104674
  1. 2
      src/core/benchmark/codec.cc
  2. 10
      src/core/benchmark/group.cc
  3. 8
      src/core_ffi/CMakeLists.txt
  4. 2
      src/core_ffi/c_ffi/all_cases.cc
  5. 6
      src/core_test/helper/internal/parallel.cc

2
src/core/benchmark/codec.cc

@ -18,7 +18,7 @@ using klotski::codec::CommonCode;
static std::vector<uint64_t> all_common_codes() {
std::vector<uint64_t> codes;
for (uint64_t head = 0; head < 16; ++head) {
for (const auto range : AllCases::instance().fetch()[head]) {
for (const auto range : AllCases::instance().fetch().ranges(head)) {
codes.emplace_back(head << 32 | range);
}
}

10
src/core/benchmark/group.cc

@ -26,7 +26,7 @@ using klotski::codec::CommonCode;
static std::vector<uint64_t> all_common_codes() {
std::vector<uint64_t> codes;
for (uint64_t head = 0; head < 16; ++head) {
for (const auto range : AllCases::instance().fetch()[head]) {
for (const auto range : AllCases::instance().fetch().ranges(head)) {
codes.emplace_back(head << 32 | range);
}
}
@ -342,7 +342,7 @@ static void FastObtainCode(benchmark::State &state) {
size_t offset = 0;
for (int i = 0; i < 16; ++i) {
sizes[i] = offset;
offset += data[i].size();
offset += data.ranges(i).size();
}
std::vector infos {
@ -376,14 +376,14 @@ static void FastObtainCode(benchmark::State &state) {
uint64_t head = 0;
auto case_id = info.case_id();
for (;;) {
if (case_id >= cases[head].size()) {
case_id -= cases[head].size();
if (case_id >= cases.ranges(head).size()) {
case_id -= cases.ranges(head).size();
++head;
} else {
break;
}
}
auto range = cases[head][case_id];
auto range = cases.ranges(head)[case_id];
volatile auto kk = CommonCode::unsafe_create(head << 32 | range);
/// about 117ns

8
src/core_ffi/CMakeLists.txt

@ -19,13 +19,13 @@ if (KLSK_RUST_FFI)
install(TARGETS klotski_core DESTINATION .)
else()
# just for IDE highlight
add_library(klotski_rust
add_library(klotski_rs
rust_ffi/adapter/short_code.cc
rust_ffi/adapter/common_code.cc
rust_ffi/target/cxxbridge/rust_ffi/src/bridge.rs.cc
)
target_include_directories(klotski_rust PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(klotski_rust PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/rust_ffi/target/cxxbridge)
target_link_libraries(klotski_rust PRIVATE klotski_core)
target_include_directories(klotski_rs PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(klotski_rs PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/rust_ffi/target/cxxbridge)
target_link_libraries(klotski_rs PRIVATE klotski_core)
endif()
endif()

2
src/core_ffi/c_ffi/all_cases.cc

@ -64,7 +64,7 @@ const uint32_t* all_cases_export(const int head) {
if (all_cases_num(head) < 0) {
return nullptr;
}
return AllCases::instance().fetch()[head].data();
return AllCases::instance().fetch().ranges(head).data();
}
// ------------------------------------------------------------------------------------- //

6
src/core_test/helper/internal/parallel.cc

@ -44,7 +44,7 @@ void helper::common_code_parallel(std::function<void(std::span<CommonCode>)> &&f
// TODO: enhance performance
pool.detach_blocks((uint64_t)0, codes.size(), [&func](auto start, auto end) {
pool.detach_blocks((size_t)0, codes.size(), [&func](auto start, auto end) {
func(std::span<CommonCode> {codes.data() + start, end - start});
@ -60,7 +60,7 @@ void helper::raw_code_parallel(std::function<void(std::span<RawCode>)> &&func) {
static auto codes = std::vector<RawCode> {common_codes.begin(), common_codes.end()};
BS::thread_pool pool;
pool.detach_blocks((uint64_t)0, codes.size(), [&func](auto start, auto end) {
pool.detach_blocks((size_t)0, codes.size(), [&func](auto start, auto end) {
func(std::span<RawCode> {codes.data() + start, end - start});
@ -78,7 +78,7 @@ void helper::short_code_parallel(std::function<void(std::span<ShortCode>)> &&fun
}();
BS::thread_pool pool;
pool.detach_blocks((uint64_t)0, codes.size(), [&func](auto start, auto end) {
pool.detach_blocks((size_t)0, codes.size(), [&func](auto start, auto end) {
auto span = std::span<uint32_t> {codes.data() + start, end - start};
func(std::bit_cast<std::span<ShortCode>>(span));

Loading…
Cancel
Save