Commit f8ab22b9 by liyinqiao

Support more sizes of memory pool and clean the codes.

1. Support KB size for memory pool.
2. Clean the codes: 1000000 -> 1024 * 1024.
parent 0bf05532
...@@ -100,7 +100,7 @@ namespace nts { ...@@ -100,7 +100,7 @@ namespace nts {
} \ } \
#define MAX_FILE_NAME_LENGTH 1024 * 2 #define MAX_FILE_NAME_LENGTH 1024 * 2
#define MAX_LINE_LENGTH 1024*1024 #define MAX_LINE_LENGTH 1024 * 1024
#define MAX_SENTENCE_LEN 512 #define MAX_SENTENCE_LEN 512
#define X_MILLION 1000000 #define X_MILLION 1000000
#define MAX_INT 2147483647 #define MAX_INT 2147483647
...@@ -108,7 +108,7 @@ namespace nts { ...@@ -108,7 +108,7 @@ namespace nts {
#define FIELD_SEP " ||| " #define FIELD_SEP " ||| "
#define FLOAT_MIN float(-1.0E38) #define FLOAT_MIN float(-1.0E38)
#define FLOAT16_MIN float(-65504) #define FLOAT16_MIN float(-65504)
#define MILLION 1000000 #define MILLION 1024 * 1024
#define LOG_E_10 2.302585 #define LOG_E_10 2.302585
#define LEADING_DIM 1 #define LEADING_DIM 1
......
...@@ -1400,17 +1400,38 @@ MTYPE XMem::GetMemSize(const char * size) ...@@ -1400,17 +1400,38 @@ MTYPE XMem::GetMemSize(const char * size)
bool ok = false; bool ok = false;
float num = 0; float num = 0;
if(s[len-2] == 'm' && s[len-1] == 'b'){ if (s[len-1] == 'b') {
if (s[len-2] == 'k') {
s[len-2] = 0; s[len-2] = 0;
num = (float)atof(s); num = (float)atof(s);
num /= 1024.0F;
ok = true; ok = true;
} }
if(s[len-2] == 'g' && s[len-1] == 'b'){ else if (s[len-2] == 'm') {
s[len-2] = 0; s[len-2] = 0;
num = (float)atof(s); num = (float)atof(s);
num *= 1000.0F;
ok = true; ok = true;
} }
else if (s[len-2] == 'g') {
s[len-2] = 0;
num = (float)atof(s);
num *= 1024.0F;
ok = true;
}
else if (s[len-2] >= '0' && s[len-2] <= '9') {
s[len-1] = 0;
num = (float)atof(s);
ok = true;
}
else
ShowNTErrors("Cannot transform the size into a number (in million)!");
}
else if (s[len-1] >= '0' && s[len-1] <= '9') {
num = (float)atof(s);
ok = true;
}
else
ShowNTErrors("Cannot transform the size into a number (in million)!");
delete[] s; delete[] s;
...@@ -1433,18 +1454,25 @@ MTYPE XMem::GetMemSizeInBytes(const char * size) ...@@ -1433,18 +1454,25 @@ MTYPE XMem::GetMemSizeInBytes(const char * size)
bool ok = false; bool ok = false;
float num = 0; float num = 0;
if(s[len-2] == 'm' && s[len-1] == 'b'){ if (s[len-1] == 'b') {
num = (float)GetMemSize(size) * 1000000; if (s[len-2] == 'k' || s[len-2] == 'm' || s[len-2] == 'g') {
num = (float)GetMemSize(size) * 1024 * 1024;
ok = true; ok = true;
} }
else if(s[len-2] == 'g' && s[len-1] == 'b'){ else if (s[len-2] >= '0' && s[len-2] <= '9') {
num = (float)GetMemSize(size) * 1000000; s[len-1] = 0;
num = (float)atof(s);
ok = true; ok = true;
} }
else{ else
ShowNTErrors("Cannot transform the size into a number (in Bytes)!");
}
else if (s[len-1] >= '0' && s[len-1] <= '9') {
num = (float)atof(s); num = (float)atof(s);
ok = true; ok = true;
} }
else
ShowNTErrors("Cannot transform the size into a number (in Bytes)!");
delete[] s; delete[] s;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论