Skip to content

Commit

Permalink
Adjusted memory allocation behavior (larger models will use slightly …
Browse files Browse the repository at this point in the history
…less memory)
  • Loading branch information
DanielOlson committed Sep 13, 2024
1 parent 7ccf1ea commit e45d6ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,14 @@ void Settings::assign_settings() {
this->window_size = 100 * this->max_period;
}

// medium models use less than 1 GB per thread
else if (period_memory <= 4000000) {
this->window_size = 50 * this->max_period;
}

// Large models use less than 4 GB per thread
else {
this->window_size = 50 * this->max_period;
this->window_size = 25 * this->max_period;
}

}
Expand Down Expand Up @@ -670,7 +675,7 @@ void Settings::print_memory_usage() {
dp_size *= (unsigned long long)(this->window_size + (2 * this->overlap));
printf("----------------------------\n");
printf("Maximum repeat period: %llu\n", this->max_period);
printf("Number of states: %i\n", num_states);
printf("Number of model states: %i\n", num_states);
printf("Total sequence window size: %lli\n",
(this->window_size + 2 * this->overlap));
printf("DP matrix cells: %llu\n", dp_size);
Expand All @@ -689,6 +694,7 @@ void Settings::print_memory_usage() {

printf("*Actual memory usage will be slightly greater due to "
"output repeat queue and repeat split matrices\n");
printf("============================\n");
}

// This could be done in less code with templates. Yikcy wicky yucky wucky.
Expand Down
3 changes: 1 addition & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ int main_wrapper(int argc, const char * argv[]) {
}

settings->assign_settings();
settings->print_memory_usage();
if (settings->show_memory) {
settings->print_memory_usage();
exit(0);
}

Expand Down Expand Up @@ -178,7 +178,6 @@ int main_wrapper(int argc, const char * argv[]) {
int main(int argc, const char *argv[]) {

char *reserve_memory = (char *)malloc(65536);

try {
int r = main_wrapper(argc, argv);
return r;
Expand Down

0 comments on commit e45d6ee

Please sign in to comment.