Makefile File Contents:
# Default Target.
All
Ifdef tilera_root
CC = $ (tilera_root)/BIN/TILE-GCC
Else
Ifeq ($ (Filter tile%,$ (shell uname-m)),)
$ (Error the ' tilera_root ' environment variable is not set.)
endif
CC = gcc
endif
OPT =-os
CFLAGS =-std=gnu99-wall-werror-g $ (OPT)
EXE = Multi_tile
$ (EXE). O: $ (EXE). c
$ (CC) $ (CFLAGS) $ (xflags)-c-o [email protected] $<
$ (EXE): $ (EXE). O
$ (CC) $ (ldflags) $ (xflags)-o [email protected] $<
-LTMC
All: $ (EXE)
Clean
Rm-f *.O $ (EXE)
. Phony:all Clean
Ifdef tilera_root
SIZE = 4x4
Tile_monitor = $ (tilera_root)/bin/tile-monitor
Common_args = \
--mkdir/opt/test--cd/opt/test \
--upload $ (EXE) $ (EXE)--$ (EXE)
Dev_args =--tile $ (SIZE) $ (Common_args)
Sim_args =--image $ (SIZE)--functional $ (Common_args)
Run_dev: $ (EXE)
$ (tile_monitor) $ (Dev_args)
Test_dev: $ (EXE)
SET-E-O pipefail; \
$ (tile_monitor) $ (Dev_args) \
> [email protected]; \
Diff $ (EXE). Out [email protected]
Run_sim: $ (EXE)
$ (tile_monitor) $ (Sim_args)
Test_sim: $ (EXE)
SET-E-O pipefail; \
$ (tile_monitor) $ (Sim_args) \
> [email protected]; \
Diff $ (EXE). Out [email protected]
. Phony:run_dev Test_dev Run_sim Test_sim
Else
Run: $ (EXE)
./$ (EXE)
Test: $ (EXE)
SET-E-O pipefail; \
./$ (EXE) > [email protected]; \
Diff $ (EXE). Out [email protected]
. Phony:run Test
endif
The Main.c file contains header files as follows:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <tmc/alloc.h>
#include <sys/types.h>
#include <tmc/cpus.h>
#include <tmc/task.h>
#include <tmc/udn.h>
The contents of the Main.c file are as follows:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <tmc/alloc.h>
#include <sys/types.h>
#include <tmc/cpus.h>
#include <tmc/task.h>
#include <tmc/udn.h>
We'll use n CPUs to calculate the sum of n * M integers.
#define Num_cpus 8
#define INTS_PER_CPU 1024
#define TOTAL_INTS (Num_cpus * ints_per_cpu)
static int parallelize (int count)
{
cpu_set_t CPUs;
if (tmc_cpus_get_my_affinity (&cpus)! = 0)
Tmc_task_die ("Failure in ' tmc_cpus_get_my_affinity () '.");
if (Tmc_cpus_count (&cpus) < count)
Tmc_task_die ("Insufficient CPUs (%d <%d).", Tmc_cpus_count (&cpus), count);
int watch_forked_children = Tmc_task_watch_forked_children (1);
Tmc_task_watch_forked_children (1);
int rank;
for (rank = 1; rank < count; rank++)
{
pid_t child = fork ();
if (Child < 0)
Tmc_task_die ("Failure in ' fork () '.");
if (child = = 0)//Parent process thing
{//Goto done;
if (Tmc_cpus_set_my_cpu (TMC_CPUS_FIND_NTH_CPU (&cpus, rank)) < 0)
if (TMC_CPUS_SET_MY_CPU (rank) < 0)
Tmc_task_die ("Failure in ' tmc_cpus_set_my_cpu () '.");
}
if (Child > 0)//Parent process Things
{
for (uint32_t i = 0; i < 500000; i++)//Sub-process things
printf ("childpid000\n");
}
}
Rank = 0;
(void) Tmc_task_watch_forked_children (Watch_forked_children);
Done
if (Tmc_cpus_set_my_cpu (TMC_CPUS_FIND_NTH_CPU (&cpus, rank)) < 0)
Tmc_task_die ("Failure in ' tmc_cpus_set_my_cpu () '.");
return rank;
}
int main (int argc, CHAR**ARGV)
{
Make sure we have enough CPUs.
cpu_set_t CPUs;
if (tmc_cpus_get_my_affinity (&cpus)! = 0)
Tmc_task_die ("Failure in ' tmc_cpus_get_my_affinity () '.");
Parallelize (Num_cpus);
}
Find the location of the TMC library:
[[Email protected]:0115/home]# Find/-name *tmc.so
/usr/lib32/libtmc.so
/usr/lib/libtmc.so
[[Email protected]:0115/home]# Find/-name *TMC.A
/usr/lib32/libtmc.a
/usr/lib/feedback/libtmc.a
/usr/lib/libtmc.a
[[Email protected]:0115/home]#
If you do not join-LTMC in makefile to connect to your own dynamic library libtmc.so, there will be an error during compilation:
[[Email protected]:0115/usr/tilera/examples/tmc/multi_tile]# make
Gcc-o Multi_tile MULTI_TILE.O
multi_tile.o:in function ' sum_of_sums ':
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:102:undefined reference to ' TMC_CPUS_FIND_NTH_CPU '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:103:undefined reference to ' TMC_UDN_HEADER_FROM_CPU '
multi_tile.o:in function ' tmc_cpus_get_my_affinity ':
usr/include/tmc/cpus.h:401:undefined reference to ' tmc_cpus_get_task_affinity '
multi_tile.o:in function ' Tmc_alloc_map ':
usr/include/tmc/alloc.h:328:undefined reference to ' Tmc_alloc_map_at '
multi_tile.o:in function ' main ':
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:142:undefined reference to ' Tmc_udn_init '
multi_tile.o:in function ' tmc_cpus_get_my_affinity ':
usr/include/tmc/cpus.h:401:undefined reference to ' tmc_cpus_get_task_affinity '
multi_tile.o:in function ' parallelize ':
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:48:undefined reference to ' Tmc_cpus_count '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:51:undefined reference to ' Tmc_task_watch_forked_children '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:64:undefined reference to ' Tmc_task_watch_forked_children '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:68:undefined reference to ' TMC_CPUS_FIND_NTH_CPU '
multi_tile.o:in function ' tmc_cpus_set_my_cpu ':
usr/include/tmc/cpus.h:415:undefined reference to ' TMC_CPUS_SET_TASK_CPU '
multi_tile.o:in function ' main ':
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:149:undefined reference to ' tmc_udn_activate '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:137:undefined reference to ' Tmc_task_die '
multi_tile.o:in function ' parallelize ':
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:49:undefined reference to ' Tmc_cpus_count '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:49:undefined reference to ' Tmc_task_die '
multi_tile.o:in function ' main ':
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:137:undefined reference to ' Tmc_task_die '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:137:undefined reference to ' Tmc_task_die '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:137:undefined reference to ' Tmc_task_die '
/usr/tilera/examples/tmc/multi_tile/multi_tile.c:137:undefined reference to ' Tmc_task_die '
Multi_tile.o:/usr/tilera/examples/tmc/multi_tile/multi_tile.c:137:more undefined references to ' Tmc_task_die ' Follow
Collect2:ld returned 1 exit status
Make: * * * [multi_tile] Error 1
[[Email protected]:0115/usr/tilera/examples/tmc/multi_tile]#
Error prompt, the function in the specified library could not be found.
When the-LTMC option is added, the system searches for the corresponding library file, such as a dynamic library or a static library, such as libtmc.so or LIBTMC.A, in a directory such as the default/usr/lib or/lib. If you have a library file with the same name in the same directory (both dynamic and static), such as libtmc.so and LIBTMC.A, the system first chooses to use the dynamic library libtmc.so.
To view system environment variables:
[[Email protected] ~]# env
Hostname=localhost
Selinux_role_requested=
Term=xterm
Shell=/bin/bash
histsize=1000
ssh_client=172.23.22.159 63804 22
Selinux_use_current_range=
qtdir=/usr/lib/qt-3.3
Qtinc=/usr/lib/qt-3.3/include
ssh_tty=/dev/pts/0
User=root
ls_colors=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05 ; 37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*. taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*. Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31 :*. deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*. jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*. xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*. mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*. qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv =01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*. xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:* . au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*. WAV=01;36:*.AXA=01;36:*.OGA=01;36:*.SPX=01;36:*.XSPF=01;36:
Mail=/var/spool/mail/root
Path=/opt/tilera/tileramde/tilegx/bin:/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin :/usr/bin:/opt/subversion/bin:/root/bin
Pwd=/root
Lang=zh_cn. UTF-8
Selinux_level_requested=
Ssh_askpass=/usr/libexec/openssh/gnome-ssh-askpass
Histcontrol=ignoredups
Shlvl=1
Home=/root
tilera_root=/opt/tilera/tileramde/tilegx
Logname=root
Qtlib=/usr/lib/qt-3.3/lib
Cvs_rsh=ssh
ssh_connection=172.23.22.159 63804 172.23.22.245 22
lessopen=| | /usr/bin/lesspipe.sh%s
G_broken_filenames=1
_=/bin/env
[Email protected] ~]# Vim/etc/profile
[Email protected] ~]#
View/ect/profile file Contents:
[Email protected] ~]# Vim/etc/profile
#/usr/share/doc/setup-*/uidgid File
If [$UID-gt 199] && ["' id-gn '" = "' Id-un '"]; Then
Umask 002
+ Else
022 Umask
The fi
66
in/etc/profile.d/*.sh for I; Do
If [-R "$i"]; Then
if ["${-#*i}"! = "$-"]; Then
70. "$i"
+ Else
72. "$i" >/dev/null 2>&1
-Fi
The fi
About
76
unset I
Unset-f Pathmunge
79
TILERA_ROOT=/OPT/TILERA/TILERAMDE/TILEGX
Bayi path= $TILERA _root/bin: $PATH
Tilera_root PATH
#export path= $PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
84
#svn
86
#PATH = $PATH:/opt/svn/subversion-1.9.1/bin
#export PATH
89
Svn_home=/opt/subversion
Path= export $PATH: $SVN _home/bin
92
93
94 # System wide environment and startup programs, for login setup
# Function and aliases Go IN/ETC/BASHRC
96
1000 Ulimit-u
98 Ulimit-n 65535
Ulimit-d Unlimited
Ulimit-m Unlimited
101 Ulimit-s Unlimited
102 Ulimit-t Unlimited
103 Ulimit-v Unlimited
Tilera--makefile instances