Sponsored Content
Full Discussion: Which is more expensive ?
Top Forums Programming Which is more expensive ? Post 302131762 by Perderabo on Monday 13th of August 2007 03:39:02 PM
Old 08-13-2007
I would code your first snippet but compile with an optimizer. These days optimizers will unroll loops if unrolling is advantageous. That particular loop is not a real great candidate for unrolling anyway. A better candidate would be:

for(i=0; i<100; i++) A[i]=0;

Most superscalar cpus can execute:
A[i]=0;
A[i+1]=0;
A[i+2]=0;
simultaneously. How deep it can go depends on the cpu and that's why leaving unrolling to an optimizer is a good idea. The optimizer should know the target cpu. But your case involved a system call which is different. You're only saving some loop overhead.

Apparently, if you explicitly unroll a loop when it is not advantageous, most optimizers will not reroll the loop. At least this was the case circa 1998 when my copy of "High Performance Computing" was published. If you have that book, see chapter 8, "Loop Optimizations" and chapter 9, "Understanding Parallelism". This is still a great book and it's not just for Fortran programmers.

Anyway, if you are not in control of which fd's might be open, you need to to loop up to OPEN_MAX closing them. High fd's might have been opened and then setrlimit() called lower to the max fd.
 

2 More Discussions You Might Find Interesting

1. Programming

calling pthread_self (on ubuntu), expensive?

Hi all, Is anyone aware of what operations are involved when a call to pthread_self() is made, obtaining the unique thread ID on a Ubuntu system (or even any Linux flavour)? Specifically, to retrieve the thread id, is there any locking required or atomic operations? I'm building an... (11 Replies)
Discussion started by: gorga
11 Replies

2. What is on Your Mind?

Very Expensive Running Shoes

You really should not need one third of the entire US budget to buy a pair of running shoes... even if they are name brand. What have these guys been smoking? It reminds me of the old joke... Customer: At those prices you aren't going to sell many shoes. Salesman: Ah, but all we need to do is... (4 Replies)
Discussion started by: Perderabo
4 Replies
FANN_GET_CASCADE_CANDIDATE_CHANGE_FRACTION(3)				 1			     FANN_GET_CASCADE_CANDIDATE_CHANGE_FRACTION(3)

fann_get_cascade_candidate_change_fraction - Returns the cascade candidate change fraction

SYNOPSIS
float fann_get_cascade_candidate_change_fraction (resource $ann) DESCRIPTION
The cascade candidate change fraction is a number between 0 and 1 determining how large a fraction the fann_get_MSE(3) value should change within fann_get_cascade_candidate_stagnation_epochs(3) during training of the candidate neurons, in order for the training not to stagnate. If the training stagnates, the training of the candidate neurons will be ended and the best candidate will be selected. It means that if the MSE does not change by a fraction of fann_get_cascade_candidate_change_fraction(3) during a period of fann_get_cas- cade_candidate_stagnation_epochs(3), the training of the candidate neurons is stopped because the training has stagnated. If the cascade candidate change fraction is low, the candidate neurons will be trained more and if the fraction is high they will be trained less. The default cascade candidate change fraction is 0.01, which is equalent to a 1% change in MSE. PARAMETERS
o $ann -Neural network resource. RETURN VALUES
The cascade candidate change fraction, or FALSE on error. SEE ALSO
fann_set_cascade_candidate_change_fraction(3), fann_get_MSE(3), fann_get_cascade_candidate_stagnation_epochs(3). PHP Documentation Group FANN_GET_CASCADE_CANDIDATE_CHANGE_FRACTION(3)
All times are GMT -4. The time now is 09:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy