SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: claus_stovgaard on February 06, 2019, 09:56:57 AM

Title: Number of CPUs as variable in project
Post by: claus_stovgaard on February 06, 2019, 09:56:57 AM
Have a number of project where it would be nice to have "number of cpus" as a variable.

E.g. So I can write for the Command Line: "make -j number_of_cpus+1 -f <makefile>"

Do SlickEdit have any feature for specifying -j argument based on number of cpus on the machine?
Title: Re: Number of CPUs as variable in project
Post by: Graeme on February 06, 2019, 10:52:21 AM
Not sure if this is what you want but you can use an environment variable like this
make -j %(NUMBER_OF_PROCESSORS) -f makefile

For Windows, NUMBER_OF_PROCESSORS is a system environment variable.
See this post for how to set environment variables for a workspace
https://community.slickedit.com/index.php/topic,16714.msg64622.html#msg64622 (https://community.slickedit.com/index.php/topic,16714.msg64622.html#msg64622)

so you could have
Code: [Select]
void _workspace_opened_set_cpus()
{
   switch ( _workspace_filename ) {
   case 'whatever' :
      set_env('NUM_CPUS', (_str)((int)get_env('NUMBER_OF_PROCESSORS') + 2));
   default:
      set_env('NUM_CPUS', (_str)((int)get_env('NUMBER_OF_PROCESSORS') + 1));

   }
}
Then
make -j %(NUM_CPUS) -f makefile

For Linux  - don't know.  You might have to run a shell script to set an environment variable.
execute('my_shell_script.sh');
execute is a slick C command.
Title: Re: Number of CPUs as variable in project
Post by: Dan on February 06, 2019, 11:12:08 AM
How many projects are in your workspace?
Title: Re: Number of CPUs as variable in project
Post by: claus_stovgaard on February 06, 2019, 11:40:43 AM
Thanks for the help with the environment variable. I think I can fix it with this.
A very good idea to use it like this.
@Dan - usually only 1 project.