HIDDEN void
parallel_interface_arg(struct thread_data *user_thread_data)
{
    /* keep track of our parallel ID number */
    thread_set_cpu(user_thread_data->cpu_id);

    if (user_thread_data->affinity) {
	int ret;
	/* lock us onto a core corresponding to our parallel ID number */
	ret = parallel_set_affinity(user_thread_data->cpu_id);
	if (ret) {
	    bu_log("WARNING: encountered unexpected problem setting CPU affinity\n");
	}
    }

    bu_semaphore_acquire(BU_SEM_THREAD);
    user_thread_data->parent->started++;
    bu_semaphore_release(BU_SEM_THREAD);

    (*(user_thread_data->user_func))(user_thread_data->cpu_id, user_thread_data->user_arg);

    bu_semaphore_acquire(BU_SEM_THREAD);
    user_thread_data->parent->finished++;
    bu_semaphore_release(BU_SEM_THREAD);

    parallel_mapping(PARALLEL_PUT, user_thread_data->cpu_id, 0);

}
Beispiel #2
0
HIDDEN void
parallel_interface_arg(struct thread_data *user_thread_data)
{
    /* keep track of our parallel ID number */
    thread_set_cpu(user_thread_data->cpu_id);

    if (user_thread_data->affinity) {
	int ret;
	/* lock us onto a core corresponding to our parallel ID number */
	ret = parallel_set_affinity(user_thread_data->cpu_id);
	if (ret) {
	    bu_log("WARNING: encountered unexpected problem setting CPU affinity\n");
	}
    }

    if (!user_thread_data->counted) {
	bu_semaphore_acquire(BU_SEM_SYSCALL);
	parallel_nthreads_started++;
	bu_semaphore_release(BU_SEM_SYSCALL);
    }

    (*(user_thread_data->user_func))(user_thread_data->cpu_id, user_thread_data->user_arg);

    if (!user_thread_data->counted) {
	bu_semaphore_acquire(BU_SEM_SYSCALL);
	parallel_nthreads_finished++;
	bu_semaphore_release(BU_SEM_SYSCALL);
    }
}