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_STAGNATION_EPOCHS(3) 			 1			   FANN_GET_CASCADE_CANDIDATE_STAGNATION_EPOCHS(3)

fann_get_cascade_candidate_stagnation_epochs - Returns the number of cascade candidate stagnation epochs

SYNOPSIS
float fann_get_cascade_candidate_stagnation_epochs (resource $ann) DESCRIPTION
The number of cascade candidate stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of fann_get_cascade_candidate_change_fraction(3). See more info about this parameter in fann_get_cascade_candidate_change_fraction(3). The default number of cascade candidate stagnation epochs is 12. PARAMETERS
o $ann -Neural network resource. RETURN VALUES
The number of cascade candidate stagnation epochs, or FALSE on error. SEE ALSO
fann_set_cascade_candidate_stagnation_epochs(3), fann_get_cascade_candidate_change_fraction(3). PHP Documentation Group FANN_GET_CASCADE_CANDIDATE_STAGNATION_EPOCHS(3)
All times are GMT -4. The time now is 09:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy