= Multicore apps = The average number of cores per PC will increase over the next few years, possibly at a faster rate than the average amount of available RAM. Depending on your application and project, it may be desirable to develop a multi-thread application. Possible reasons to do this: * Your application's memory footprint is large enough that, on some PCs, there's not enough RAM to run a separate copy of the app on each CPU. * You want to reduce the turnaround time of your jobs (either because of human factors, or to reduce server occupancy). You may be able to use OpenCL, MPI, OpenMP, [http://blogs.nvidia.com/2011/06/cuda-now-available-for-multiple-x86-processors/ CUDA], languages like Titanium or Cilk, or libraries of multi-threaded numerical "kernels", to develop a multi-threaded app. == Initialization == You will need to use [BasicApi#Parallelapps the appropriate initialization function]. == Waiting for children == If your application uses multiple process, the parent process must always wait for children to exit before exiting itself. == Thread priorities == You should set the priority of new threads to that of the main thread. {{{ #ifdef MSVC #define getThreadPriority() GetThreadPriority(GetCurrentThread()) #define setThreadPriority(num) SetThreadPriority(GetCurrentThread(), num) #else #include #define getThreadPriority() getpriority(PRIO_PROCESS, 0) #define setThreadPriority(num) nice(num) #endif }}} getThreadPriority() is called before forking (by OpenMP in AQUA's case), and setThreadPriority() is then called by each worker thread. == Specifying a plan class == Multicore apps must the [AppPlan plan class] mechanism to specify their properties. You may be able to use the [AppPlan predefined "mt" class]. Otherwise you must specify your own, using either [AppPlanSpec XML] or [PlanClassFunc C++].