Skip to content Skip to navigation

Connexions

You are here: Home » Content » Qué Hace un Compilador - Ejercicios

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

Exercise 1

¿Su compilador reconoce el código muerto en el siguiente programa? ¿Cómo puede estar seguro? ¿Le envía el compilador algún aviso?


main() { int k=1; if (k == 0) printf ("Esta sentencia nunca se ejecuta.\n"); }

Exercise 2

Compile el siguiente código, y ejecútelo bajo distintos niveles de optimización.

Trate de adivinar los distintos tipos de optimizaciones que se están realizando para mejorar el rendimiento, conforme se incrementa el nivel de optimización.


REAL*8 A(1000000) DO I=1,1000000 A(I) = 3.1415927 ENDDO DO I=1,1000000 A(I) = A(I) * SIN(A(I)) + COS(A(I)) ENDDO PRINT *,"Terminado"

Exercise 3

Tome el siguiente segmento de código y compílelo a varios niveles de optimización. Observe el código ensamblador generado (en algunos compiladores esto se hace con la opción -S) y encuentre los efectos de cada nivel de optimización sobre el lenguaje máquina. Mida el tiempo de ejecución del programa para ver el rendimiento a diferentes niveles de optimización. Si tiene acceso a múltiples arquitecturas, observe el código generado usando los mismos niveles de optimización sobre diferentes arquitecturas.


REAL*8 A(1000000) COMMON/BLK/A .... Llamada para medir el tiempo DO I=1,1000000 A(I) = A(I) + 1.234 ENDDO .... Llamada para medir el tiempo END

¿Por qué es necesario poner el arreglo adentro de un bloque común?

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks