Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for cache size > 2000 #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions svm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void info(const char *fmt,...) {}
class Cache
{
public:
Cache(int l,long int size);
Cache(int l,long long size);
~Cache();

// request data [0,len)
Expand All @@ -77,7 +77,7 @@ class Cache
void swap_index(int i, int j);
private:
int l;
long int size;
long long size;
struct head_t
{
head_t *prev, *next; // a circular list
Expand All @@ -91,12 +91,12 @@ class Cache
void lru_insert(head_t *h);
};

Cache::Cache(int l_,long int size_):l(l_),size(size_)
Cache::Cache(int l_,long long size_):l(l_),size(size_)
{
head = (head_t *)calloc(l,sizeof(head_t)); // initialized to 0
size /= sizeof(Qfloat);
size -= l * sizeof(head_t) / sizeof(Qfloat);
size = max(size, 2 * (long int) l); // cache must be large enough for two columns
size = max(size, 2 * (long long) l); // cache must be large enough for two columns
lru_head.next = lru_head.prev = &lru_head;
}

Expand Down Expand Up @@ -1270,7 +1270,7 @@ class SVC_Q: public Kernel
:Kernel(prob.l, prob.x, param)
{
clone(y,y_,prob.l);
cache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));
cache = new Cache(prob.l,(long long)(param.cache_size*(1<<20)));
QD = new double[prob.l];
for(int i=0;i<prob.l;i++)
QD[i] = (this->*kernel_function)(i,i);
Expand Down Expand Up @@ -1319,7 +1319,7 @@ class ONE_CLASS_Q: public Kernel
ONE_CLASS_Q(const svm_problem& prob, const svm_parameter& param)
:Kernel(prob.l, prob.x, param)
{
cache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));
cache = new Cache(prob.l,(long long)(param.cache_size*(1<<20)));
QD = new double[prob.l];
for(int i=0;i<prob.l;i++)
QD[i] = (this->*kernel_function)(i,i);
Expand Down Expand Up @@ -1366,7 +1366,7 @@ class SVR_Q: public Kernel
:Kernel(prob.l, prob.x, param)
{
l = prob.l;
cache = new Cache(l,(long int)(param.cache_size*(1<<20)));
cache = new Cache(l,(long long)(param.cache_size*(1<<20)));
QD = new double[2*l];
sign = new schar[2*l];
index = new int[2*l];
Expand Down