diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-04-05 23:15:05 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-04-05 23:15:05 +0200 |
commit | 6eb1ca1dd4b0bda6433923a65ab9e1ed3b268c10 (patch) | |
tree | 6e7ef978d39718f98291ae8a220525af05d7c96b | |
parent | 46d3cf490464eab10134c9b14e180a77b0976fed (diff) |
-rw-r--r-- | attract.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -10,6 +10,19 @@ #include <assert.h> #include "lodepng.h" +#ifdef _WIN32 +#include <windows.h> +int number_of_cores(void){ + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + return sysinfo.dwNumberOfProcessors; +} +#else +int number_of_cores(void){ + return sysconf(_SC_NPROCESSORS_ONLN); +} +#endif + #ifndef CMPLX #define CMPLX(r,i) ((r) + (i)*I) #endif @@ -134,8 +147,8 @@ static void* thread_entry(void *arg_vp){ } int main(int argc,char **argv){ - const double minx=-1.5,miny=-1.5; - const double maxx=1.5,maxy=1.5; + const double minx=-0.3,miny=0.6; + const double maxx=-0.1,maxy=0.8; const double width=1000; struct config cfg={ @@ -165,9 +178,9 @@ int main(int argc,char **argv){ unsigned char *img=malloc(cfg.width*cfg.height*3); - int nthreads=sysconf(_SC_NPROCESSORS_ONLN); - if(nthreads==4)nthreads/=2; + int nthreads=number_of_cores(); if(nthreads>=999||nthreads<1)nthreads=1; + // nthreads=1; fprintf(stderr,"Using %d thread%s\n",nthreads,nthreads==1?"":"s"); |