Fix small matters and improve sysconf()

- Fix mkdeps.com out of memory error
- Remove static memory from __get_cpu_count()
- Add support for passing hyphen to cat in cocmd
- Change more ZipOS errors from ENOTSUP to EROFS
- Specify mem_unit in sysinfo() output on BSD OSes
This commit is contained in:
Justine Tunney 2023-08-17 00:25:01 -07:00
parent eebc24b9cd
commit 3a9cac4892
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
55 changed files with 411 additions and 262 deletions

View file

@ -88,7 +88,7 @@ static bool append_file_to_prompt(const char *path, gpt_params & params) {
}
bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
params.n_threads = std::min(20, std::max(1, _getcpucount() >> 1));
params.n_threads = std::min(20., (unsigned)__get_cpu_count() * .75);
bool invalid_param = false;
std::string arg;

View file

@ -21,7 +21,7 @@
struct gpt_params {
int32_t seed = -1; // RNG seed
int32_t verbose = 0; // Logging verbosity
int32_t n_threads = std::max(1, _getcpucount() >> 1);
int32_t n_threads = std::max(20., (unsigned)__get_cpu_count() * .75);
int32_t n_predict = -1; // new tokens to predict
int32_t n_parts = -1; // amount of model parts (-1 = determine from model dimensions)
int32_t n_ctx = 512; // context size

View file

@ -92,7 +92,7 @@ int main(int argc, char ** argv) {
ftype = (enum llama_ftype)atoi(argv[3]);
}
int nthread = argc > 4 ? atoi(argv[4]) : std::min(20, std::max(1, _getcpucount() >> 1));
int nthread = argc > 4 ? atoi(argv[4]) : std::min(20, std::max(1, __get_cpu_count() >> 1));
const int64_t t_main_start_us = ggml_time_us();

View file

@ -3532,7 +3532,7 @@ int LuaUnix(lua_State *L) {
LuaSetIntField(L, "RUSAGE_CHILDREN", RUSAGE_CHILDREN);
LuaSetIntField(L, "RUSAGE_BOTH", RUSAGE_BOTH);
LuaSetIntField(L, "ARG_MAX", __arg_max());
LuaSetIntField(L, "ARG_MAX", __get_arg_max());
LuaSetIntField(L, "BUFSIZ", BUFSIZ);
LuaSetIntField(L, "CLK_TCK", CLK_TCK);
LuaSetIntField(L, "NAME_MAX", _NAME_MAX);

View file

@ -10509,7 +10509,7 @@ os_cpu_count_impl(PyObject *module)
/*[clinic end generated code: output=5fc29463c3936a9c input=e7c8f4ba6dbbadd3]*/
{
int ncpu;
ncpu = _getcpucount();
ncpu = __get_cpu_count();
if (ncpu >= 1)
return PyLong_FromLong(ncpu);
else

View file

@ -39,7 +39,7 @@
// clang-format off
bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
params.n_threads = std::min(20, std::max(1, (int)(_getcpucount() * 0.75)));
params.n_threads = std::min(20., (unsigned)__get_cpu_count() * 0.75);
bool invalid_param = false;
std::string arg;

View file

@ -19,7 +19,7 @@
struct gpt_params {
int32_t seed = -1; // RNG seed
int32_t n_threads = MIN(4, (int32_t) _getcpucount() * 0.75);
int32_t n_threads = MIN(20., (unsigned) __get_cpu_count() * 0.75);
int32_t n_predict = 128; // new tokens to predict
int32_t n_parts = -1; // amount of model parts (-1 = determine from model dimensions)
int32_t n_ctx = 512; // context size