Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
austindonisan committed Feb 23, 2024
1 parent b0c02bb commit 0ed37de
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions 1brc.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ typedef struct {
bool warmup;
bool first;
bool last;
} worker_t;
} Worker;


typedef struct {
Expand Down Expand Up @@ -135,9 +135,9 @@ typedef struct {
LongCity * restrict longCities;
} Results;

void prep_workers(worker_t *workers, int numWorkers, bool warmup, int fd, struct stat *fileStat);
void process(int id, worker_t * workers, int numWorkers, int fd, Results *out);
void start_worker(worker_t *w, Results *out);
void prep_workers(Worker *workers, int numWorkers, bool warmup, int fd, struct stat *fileStat);
void process(int id, Worker *workers, int numWorkers, int fd, Results *out);
void start_worker(Worker *w, Results *out);
void process_chunk(const void * const restrict base, const unsigned int * offsets, hash_t * restrict h);
__m256i process_long(const void * const restrict start, hash_t * restrict h, int * restrict semicolonBytesOut);
inline __m256i hash_cities(__m256i a, __m256i b, __m256i c, __m256i d, __m256i e, __m256i f, __m256i g, __m256i h);
Expand Down Expand Up @@ -283,13 +283,13 @@ int main(int argc, char** argv) {
numWorkers = (int) (fileStat.st_size / PAGE_SIZE) + 1;
}

void *mem = mmap(NULL, RESULTS_MEMORY_SIZE + sizeof(worker_t) * numWorkers, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
void *mem = mmap(NULL, RESULTS_MEMORY_SIZE + sizeof(Worker) * numWorkers, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
Results *results = mem;
setup_results(results);

mem += RESULTS_MEMORY_SIZE;

worker_t *workers = mem;
Worker *workers = mem;
prep_workers(workers, numWorkers, warmup, fd, &fileStat);

TIMER_RESET();
Expand All @@ -313,7 +313,7 @@ int main(int argc, char** argv) {
return 0;
}

void prep_workers(worker_t *workers, int numWorkers, bool warmup, int fd, struct stat *fileStat) {
void prep_workers(Worker *workers, int numWorkers, bool warmup, int fd, struct stat *fileStat) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
sched_getaffinity(0, sizeof(cpu_set_t), &cpuset);
Expand All @@ -332,7 +332,7 @@ void prep_workers(worker_t *workers, int numWorkers, bool warmup, int fd, struct
cpu++;
}

worker_t *w = workers + i;
Worker *w = workers + i;
w->workerId = i;
w->cpuId = cpu++;
w->fd = fd;
Expand Down Expand Up @@ -408,7 +408,7 @@ void merge(Results * restrict dst, Results * restrict src) {
}
}

void process(int id, worker_t * workers, int numWorkers, int fdOut, Results *out) {
void process(int id, Worker * workers, int numWorkers, int fdOut, Results *out) {
TIMER_INIT();

int max_k = 8;
Expand Down Expand Up @@ -571,7 +571,7 @@ void convert_hash_to_results(hash_t * restrict hash, Results * restrict out) {
}


void start_worker(worker_t *w, Results *out) {
void start_worker(Worker *w, Results *out) {
TIMER_INIT();

// 4k pages at the front for the offsets, 2MB pagesfor the everything else
Expand All @@ -598,7 +598,7 @@ void start_worker(worker_t *w, Results *out) {
void * hashedCitiesLong = hashData;
hashData += HASHED_CITIES_LONG_SIZE;

hash_t hash = {{packedOffsets, hashedCities, hashedStorage, hashedCitiesLong}, {0 ,0}};
hash_t hash = {{packedOffsets, hashedCities, hashedStorage, hashedCitiesLong}, {0, 0}};

void * const data = mmap(NULL, MMAP_DATA_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

Expand All @@ -617,7 +617,7 @@ void start_worker(worker_t *w, Results *out) {
unsigned int chunk_size = (unsigned int)(end - start);
unsigned int mapped_file_length = last ? PAGE_CEIL(chunk_size) : chunk_size + PAGE_SIZE;

mmap(data + DUMMY_SIZE, mapped_file_length, PROT_READ, MAP_PRIVATE | MAP_FIXED , w->fd, start);
mmap(data + DUMMY_SIZE, mapped_file_length, PROT_READ, MAP_PRIVATE | MAP_FIXED, w->fd, start);

if (DEBUG && w->warmup) {
long dummy = 0;
Expand Down

0 comments on commit 0ed37de

Please sign in to comment.