Browse Source

update: lambda or inline function will loss speed

legacy
Dnomd343 2 years ago
parent
commit
84e54dfe95
  1. 47
      src/core_demo.cc

47
src/core_demo.cc

@ -22,6 +22,16 @@ inline bool cache_insert(cache_t &new_item) {
return true; return true;
} }
//inline void demo(uint64_t code, int addr, int next_addr, int f) {
// cache_t next_case = {
// .code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr),
// .mask = (uint64_t)0b111 << next_addr,
// .filter = f,
// .addr = next_addr
// };
// cache_insert(next_case);
//}
void move_1x1_demo(uint64_t code, int addr) { void move_1x1_demo(uint64_t code, int addr) {
cache_size = 1; cache_size = 1;
@ -31,22 +41,29 @@ void move_1x1_demo(uint64_t code, int addr) {
int count = 0; int count = 0;
int next_addr;
// auto demo = [&](int f) {
// cache_t next_case = {
// .code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr),
// .mask = (uint64_t)0b111 << next_addr,
// .filter = f,
// .addr = next_addr
// };
// cache_insert(next_case);
// };
while (count != cache_size) { while (count != cache_size) {
code = cache[count].code; code = cache[count].code;
addr = cache[count].addr; addr = cache[count].addr;
int filter = cache[count].filter; int filter = cache[count].filter;
++count; ++count;
uint64_t ret_code;
int next_addr;
/// try to move up /// try to move up
if (filter != UP && addr >= 4 * 3 && !(code >> (next_addr = addr + UP) & F_1x1)) { if (filter != UP && addr >= 4 * 3 && !(code >> (next_addr = addr + UP) & F_1x1)) {
// ret_code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr);
cache_t next_case = { cache_t next_case = {
.code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr), .code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr),
.mask = (uint64_t)0b111 << next_addr, .mask = (uint64_t)0b111 << next_addr,
@ -54,12 +71,12 @@ void move_1x1_demo(uint64_t code, int addr) {
.addr = next_addr .addr = next_addr
}; };
cache_insert(next_case); cache_insert(next_case);
// demo(DOWN);
// demo(code, addr, next_addr, DOWN);
} }
/// try to move down /// try to move down
if (filter != DOWN && addr <= 15 * 3 && !(code >> (next_addr = addr + DOWN) & F_1x1)) { if (filter != DOWN && addr <= 15 * 3 && !(code >> (next_addr = addr + DOWN) & F_1x1)) {
// ret_code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr);
cache_t next_case = { cache_t next_case = {
.code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr), .code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr),
.mask = (uint64_t)0b111 << next_addr, .mask = (uint64_t)0b111 << next_addr,
@ -67,12 +84,12 @@ void move_1x1_demo(uint64_t code, int addr) {
.addr = next_addr .addr = next_addr
}; };
cache_insert(next_case); cache_insert(next_case);
// demo(UP);
// demo(code, addr, next_addr, UP);
} }
/// try to move left /// try to move left
if (filter != LEFT && (addr & 0b11) != 0 && !(code >> (next_addr = addr + LEFT) & F_1x1)) { if (filter != LEFT && (addr & 3) != 0 && !(code >> (next_addr = addr + LEFT) & F_1x1)) {
ret_code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr);
cache_t next_case = { cache_t next_case = {
.code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr), .code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr),
.mask = (uint64_t)0b111 << next_addr, .mask = (uint64_t)0b111 << next_addr,
@ -80,12 +97,12 @@ void move_1x1_demo(uint64_t code, int addr) {
.addr = next_addr .addr = next_addr
}; };
cache_insert(next_case); cache_insert(next_case);
// demo(RIGHT);
// demo(code, addr, next_addr, RIGHT);
} }
/// try to move right /// try to move right
if (filter != RIGHT && (addr & 0x3) != 1 && !(code >> (next_addr = addr + RIGHT) & F_1x1)) { if (filter != RIGHT && (addr & 3) != 1 && !(code >> (next_addr = addr + RIGHT) & F_1x1)) {
// ret_code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr);
cache_t next_case = { cache_t next_case = {
.code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr), .code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr),
.mask = (uint64_t)0b111 << next_addr, .mask = (uint64_t)0b111 << next_addr,
@ -93,9 +110,9 @@ void move_1x1_demo(uint64_t code, int addr) {
.addr = next_addr .addr = next_addr
}; };
cache_insert(next_case); cache_insert(next_case);
// demo(LEFT);
// demo(code, addr, next_addr, LEFT);
} }
} }

Loading…
Cancel
Save