Index: /soft/giet_vm/applications/coremark/Makefile
===================================================================
--- /soft/giet_vm/applications/coremark/Makefile	(revision 755)
+++ /soft/giet_vm/applications/coremark/Makefile	(revision 756)
@@ -1,4 +1,5 @@
 
 APP_NAME = coremark
+TARGET   = appli.elf
 
 OBJS= core_main.o \
@@ -10,37 +11,38 @@
 
 LIBS= -L../../build/libs -luser
+INCLUDES = -I. -I./mach  -I../..  -I../../giet_libs  -I../../giet_xml
 
-INCLUDES = -I. -I./mach  -I../..  -I../../giet_libs  -I../../giet_xml  
-
-DEFS := -DFLAGS_STR="\"${CFLAGS}\"" -DTOTAL_DATA_SIZE=2000
+LIBS   := $(LIBS) $(XLIBS) 
+CFLAGS := $(CFLAGS) $(XCFLAGS)
 
 COREMARK ?= RUN1
-ifeq (${COREMARK},RUN1)
+ifeq ($(COREMARK),RUN1)
   $(info Coremark Performance Run)
-  DEFS := ${DEFS} -DPERFORMANCE_RUN=1
+  CFLAGS := $(CFLAGS) -DPERFORMANCE_RUN=1
 endif
-ifeq (${COREMARK},RUN2)
+ifeq ($(COREMARK),RUN2)
   $(info Coremark Validation Run)
-  DEFS := ${DEFS} -DVALIDATION_RUN=1
+  CFLAGS := $(CFLAGS) -DVALIDATION_RUN=1
 endif
-ifeq (${COREMARK},RUN3)
+ifeq ($(COREMARK),RUN3)
   $(info Coremark Profile Run)
-  DEFS := ${DEFS} -DPROFILE_RUN=1
+  CFLAGS := $(CFLAGS) -DPROFILE_RUN=1
 endif
 
-#DEFS := ${DEFS} -DCORE_DEBUG=1
+CFLAGS := $(CFLAGS) -DFLAGS_STR="\"$(CFLAGS)\""
+LDFLAGS := -Wl,-T $(APP_NAME).ld $(CFLAGS)
 
 LIB_DEPS = ../../build/libs/libuser.a
 
-appli.elf: $(OBJS) $(APP_NAME).ld $(LIBS_DEPS) 
-	$(LD) -o $@ -T $(APP_NAME).ld $(OBJS) $(LIBS)
+$(TARGET): $(OBJS) $(APP_NAME).ld $(LIBS_DEPS)
+	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
 	$(DU) -D $@ > $@.txt
 
 check_coremark: coremark.md5
-	md5sum -c $< 
+	md5sum -c $<
 
-%.o: %.c 
-	$(CC)  $(INCLUDES) $(CFLAGS) ${DEFS} -c -o  $@ $<
+%.o: %.c
+	$(CC) $(INCLUDES) $(CFLAGS) -c -o  $@ $<
 
 clean:
-	rm -f *.o *.elf appli.elf.txt *.pyc core *~
+	rm -f $(OBJS) $(TARGET) $(TARGET).txt $(APP_NAME).pyc
Index: /soft/giet_vm/applications/coremark/coremark.py
===================================================================
--- /soft/giet_vm/applications/coremark/coremark.py	(revision 755)
+++ /soft/giet_vm/applications/coremark/coremark.py	(revision 756)
@@ -90,5 +90,5 @@
                        'main_stack',
                        'coremark_heap_0_0',
-                       1 )                      # index in start_vector
+                       2 )                      # index in start_vector
 
     for x in xrange (x_size):
@@ -101,5 +101,5 @@
                                        'coremark_stack_%d_%d_%d' % (x,y,p),
                                        'coremark_heap_%d_%d' % (x,y),
-                                       0 )
+                                       1 )
 
     # extend mapping name
Index: /soft/giet_vm/applications/coremark/mach/core_portme.c
===================================================================
--- /soft/giet_vm/applications/coremark/mach/core_portme.c	(revision 755)
+++ /soft/giet_vm/applications/coremark/mach/core_portme.c	(revision 756)
@@ -35,5 +35,5 @@
         during the benchmark's execution
 */
-volatile ee_s32 seed4_volatile=0;
+volatile ee_s32 seed4_volatile=ITERATIONS;
 
 
@@ -56,5 +56,5 @@
 */
 #define TIMER_RES_DIVIDER 1
-#define NSECS_PER_SEC 1000000 /* 1 GHz */
+#define NSECS_PER_SEC 833000000 /* 833 MHz */
 #define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
 #define GETMYTIME(_t) (*_t=giet_proctime())
@@ -113,5 +113,5 @@
 }
 
-ee_u32 default_num_contexts=1;
+ee_u32 default_num_contexts=MULTITHREAD;
 
 
@@ -136,7 +136,4 @@
 	giet_procs_number( &x_size, &y_size, &nprocs );
 	
-	// one context per core when using multiple threads
-	default_num_contexts = x_size * y_size * nprocs; 
-
 	// initialize distributed heaps
 	int x, y;
@@ -146,7 +143,4 @@
 		}
 	}
-	
-	// FIXME: init a lock to access the TTY, and create a printf wrapper,
-	// requiring and releasing the lock
 #else
 	// initialize local heap
@@ -165,4 +159,13 @@
 void portable_fini(core_portable *p)
 {
+	core_results *res = (core_results*)((char*)p - 
+			(sizeof(core_results) - sizeof(core_portable)));
+
+	int i;
+	for (i=0 ; i<default_num_contexts; i++) {
+		const CORE_TICKS total_time = res[i].port.stop_time - res[i].port.start_time;
+		printf("thread %d: total ticks = %d\n", i, total_time);
+	}
+
 	p->portable_id=0;
 }
@@ -177,5 +180,8 @@
 __attribute__ ((constructor))  
 void *__iterate(void *pres) {
+	core_results *res = (core_results*)pres; 
+	GETMYTIME(&(res->port.start_time));
 	iterate(pres);
+	GETMYTIME(&(res->port.stop_time));
 	giet_pthread_exit(NULL);
 	return NULL;
Index: /soft/giet_vm/applications/coremark/mach/core_portme.h
===================================================================
--- /soft/giet_vm/applications/coremark/mach/core_portme.h	(revision 755)
+++ /soft/giet_vm/applications/coremark/mach/core_portme.h	(revision 756)
@@ -182,6 +182,22 @@
 
 
+/* Configuration : ITERATIONS
+	Valid values :
+	0 - the actual number of iterations is computed by the benchmark.
+	N > 0 - fixed number of iterations
+*/
+#ifndef ITERATIONS
+#define ITERATIONS 0
+#endif
+
+
+/* Configuration : TOTAL_DATA_SIZE
+*/
+#ifndef TOTAL_DATA_SIZE
+#define TOTAL_DATA_SIZE 2000
+#endif
+
+
 /* Variable : default_num_contexts
-	Not used for this simple port, must cintain the value 1.
 */
 extern ee_u32 default_num_contexts;
@@ -190,4 +206,6 @@
 	ee_u8	    portable_id;
 	pthread_t   thread;
+
+	CORE_TICKS  start_time, stop_time;
 } core_portable;
 
