Go Back   AC3D Forums > General > AC3D Suggestions
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 17th December 2020, 12:43 AM   #1
Advanced member
Join Date: Nov 2003
Posts: 34
Default Overall support for multicore cpu

It seems the function calls does not work with parallel processing using multicore cpu. I use Openmp in some of my plugins but calling ac3d functions does not work. I can only get Openmp to work with code that does not use ac3d functions.
Here is an example code to process a list of vertices. This example divides a list of vertices depending on the number of vertices and number of cpu cores. The code then process the divided list in parallel.

typedef struct pair2_t
List* start, * end;
} Pair2;

int numvert1 = list_count(selver);

int cores = numvert1 / 100;
if (cores == 0)
cores = 1;
if (cores > omp_get_num_procs())
cores = omp_get_num_procs();

if (cores > 1)

int vertpercore = numvert1 / cores;
Pair2* p;
p = (Pair2*)_aligned_malloc(sizeof(Pair2) * cores, 16);
List* tl = NULL;
int i = 1;
int corecount = 0;
p[0].start = selver;
for (tl = selver; tl != NULL; tl = tl->next)

if (i == vertpercore * (corecount + 1))
p[corecount].end = tl->next;
if ((corecount + 1) < cores)
p[corecount].start = tl->next;
p[corecount].end = tl;

#pragma omp parallel for num_threads (cores) private(i)
for (i = 0; i < cores; i++)

getplanes(p[i].start, distance, p[i].end);

fprintf(file, "vertex count %d\n", numvert1);
fprintf(file, "number of cores %d\n", cores);
fprintf(file, "vertex per core %d\n", vertpercore);
for (i = 0; i < cores; i++)
fprintf(file, "core %d start %p end %p\n", i, p[i].start, p[i].end);


getplanes(selver, distance, NULL);

modeler is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 10:46 AM.

AC3D Forum
(C) Inivis Limited 2020