feat: update

This commit is contained in:
tqcq 2024-10-21 02:24:36 +00:00
parent 1664f69810
commit 247d35ecb1

View File

@ -1,114 +1,119 @@
#include "stdio.h" #include "stdio.h"
// #include <x86intrin.h> /* for rdtsc, rdtscp, clflush */ // #include <x86intrin.h> /* for rdtsc, rdtscp, clflush */
#include <stdint.h>
#include <assert.h> #include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sched.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdbool.h>
#include <getopt.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <sched.h>
#include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include "include/utils.h"
#include "include/types.h"
#include "include/allocator.h" #include "include/allocator.h"
#include "include/memory.h"
#include "include/dram-address.h" #include "include/dram-address.h"
#include "include/hammer-suite.h" #include "include/hammer-suite.h"
#include "include/memory.h"
#include "include/params.h" #include "include/params.h"
#include "include/types.h"
#include "include/utils.h"
ProfileParams *p; ProfileParams *p;
// DRAMLayout g_mem_layout = {{{0x4080,0x88000,0x110000,0x220000,0x440000,0x4b300}, 6}, 0xffff80000, ((1<<13)-1)}; // DRAMLayout g_mem_layout = {{{0x4080,0x88000,0x110000,0x220000,0x440000,0x4b300}, 6}, 0xffff80000, ((1<<13)-1)};
// DRAMLayout g_mem_layout = { {{0x2040, 0x44000, 0x88000, 0x110000, 0x220000}, 5}, 0xffffc0000, ((1 << 13) - 1) }; // DRAMLayout g_mem_layout = { {{0x2040, 0x44000, 0x88000, 0x110000, 0x220000}, 5}, 0xffffc0000, ((1 << 13) - 1) };
// DRAMLayout g_mem_layout = {{{0x2040,0x24000,0x48000,0x90000},4}, 0xffffe0000, ((1<<13)-1)}; // DRAMLayout g_mem_layout = {{{0x2040,0x24000,0x48000,0x90000},4}, 0xffffe0000, ((1<<13)-1)};
DRAMLayout g_mem_layout = {{{0x4080,0x48000,0x90000,0x120000,0x1b300}, 5}, 0xffffc0000, ROW_SIZE-1}; DRAMLayout g_mem_layout = {
{{0x5400, 0x82600}, 2},
0xffff00000,
ROW_SIZE - 1
};
void read_config(SessionConfig * cfg, char *f_name) void
read_config(SessionConfig *cfg, char *f_name)
{ {
FILE *fp = fopen(f_name, "rb"); FILE *fp = fopen(f_name, "rb");
int p_size; int p_size;
size_t res; size_t res;
assert(fp != NULL); assert(fp != NULL);
res = fread(cfg, sizeof(SessionConfig), 1, fp); res = fread(cfg, sizeof(SessionConfig), 1, fp);
assert(res == 1); assert(res == 1);
fclose(fp); fclose(fp);
return; return;
} }
void gmem_dump() void
gmem_dump()
{ {
FILE *fp = fopen("g_mem_dump.bin", "wb+"); FILE *fp = fopen("g_mem_dump.bin", "wb+");
fwrite(&g_mem_layout, sizeof(DRAMLayout), 1, fp); fwrite(&g_mem_layout, sizeof(DRAMLayout), 1, fp);
fclose(fp); fclose(fp);
#ifdef DEBUG #ifdef DEBUG
DRAMLayout tmp; DRAMLayout tmp;
fp = fopen("g_mem_dump.bin", "rb"); fp = fopen("g_mem_dump.bin", "rb");
fread(&tmp, sizeof(DRAMLayout), 1, fp); fread(&tmp, sizeof(DRAMLayout), 1, fp);
fclose(fp); fclose(fp);
assert(tmp->h_fns->len == g_mem_layout->h_fns->len); assert(tmp->h_fns->len == g_mem_layout->h_fns->len);
assert(tmp->bank == g_mem_layout->bank); assert(tmp->bank == g_mem_layout->bank);
assert(tmp->row == g_mem_layout->row); assert(tmp->row == g_mem_layout->row);
assert(tmp->col == g_mem_layout->col); assert(tmp->col == g_mem_layout->col);
#endif #endif
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
srand(time(NULL)); srand(time(NULL));
p = (ProfileParams*)malloc(sizeof(ProfileParams)); p = (ProfileParams *) malloc(sizeof(ProfileParams));
if (p == NULL) { if (p == NULL) {
fprintf(stderr, "[ERROR] Memory allocation\n"); fprintf(stderr, "[ERROR] Memory allocation\n");
exit(1); exit(1);
} }
if(process_argv(argc, argv, p) == -1) { if (process_argv(argc, argv, p) == -1) {
free(p); free(p);
exit(1); exit(1);
} }
MemoryBuffer mem = { MemoryBuffer mem = {
.buffer = NULL, .buffer = NULL,
.physmap = NULL, .physmap = NULL,
.fd = p->huge_fd, .fd = p->huge_fd,
.size = p->m_size, .size = p->m_size,
.align = p->m_align, .align = p->m_align,
.flags = p->g_flags & MEM_MASK .flags = p->g_flags & MEM_MASK};
};
alloc_buffer(&mem); alloc_buffer(&mem);
set_physmap(&mem); set_physmap(&mem);
gmem_dump(); gmem_dump();
SessionConfig s_cfg; SessionConfig s_cfg;
memset(&s_cfg, 0, sizeof(SessionConfig)); memset(&s_cfg, 0, sizeof(SessionConfig));
if (p->g_flags & F_CONFIG) { if (p->g_flags & F_CONFIG) {
read_config(&s_cfg, p->conf_file); read_config(&s_cfg, p->conf_file);
} else { } else {
// HARDCODED values // HARDCODED values
s_cfg.h_rows = PATT_LEN; s_cfg.h_rows = PATT_LEN;
s_cfg.h_rounds = p->rounds; s_cfg.h_rounds = p->rounds;
s_cfg.h_cfg = N_SIDED; s_cfg.h_cfg = N_SIDED;
s_cfg.d_cfg = RANDOM; s_cfg.d_cfg = RANDOM;
s_cfg.base_off = p->base_off; s_cfg.base_off = p->base_off;
s_cfg.aggr_n = p->aggr; s_cfg.aggr_n = p->aggr;
} }
if (p->fuzzing) { if (p->fuzzing) {
fuzzing_session(&s_cfg, &mem); fuzzing_session(&s_cfg, &mem);
} else { } else {
hammer_session(&s_cfg, &mem); hammer_session(&s_cfg, &mem);
} }
close(p->huge_fd); close(p->huge_fd);
return 0; return 0;
} }