[Cbe-oss-dev] [PATCH] libspe: hack to enable spufs gangs

Arnd Bergmann arnd at arndb.de
Fri Jun 16 08:00:58 EST 2006


This is the most simple way to test the spufs code I have
just sent. It changes libspe to always create a gang file
descriptor first before adding threads to it.

Signed-off-by: Arnd Bergmann <arnd.bergmann at de.ibm.com>

Index: spe.c
===================================================================
RCS file: /cvs/stiblade/cvs/sw/mercury-l1/libspe/spe.c,v
retrieving revision 1.17
diff -u -p -r1.17 spe.c
--- ./spe.c	4 Jun 2006 21:06:22 -0000	1.17
+++ ./spe.c	15 Jun 2006 16:43:29 -0000
@@ -367,7 +367,8 @@ spe_gid_setup(int policy, int priority, 
 	group_store->use_events = use_events;
 	group_store->grp_members = NULL;
 	group_store->numListSize = 0;
-
+	strcpy(group_store->pathname, "/spu");
+	group_store->group_fd = -1;
 	add_group_to_groups(group_store);
 	
 	return group_store;
@@ -386,14 +387,15 @@ spe_setup (spe_gid_t gid, spe_program_ha
 #endif
 	struct spe_ld_info ld_info;
 	struct spe_exec_params spe_params __attribute__ ((aligned (4096)));
+	struct group_store *grp = gid;
 	
 	if(!gid)
 	{
 		gid=spe_gid_setup(default_policy,default_priority,default_eventmask);
+		grp = gid;
 	}
 	else
 	{
-		struct group_store *grp = gid;
 		if (grp->numListSize == MAX_THREADS_PER_GROUP)
 		{
 		  	DEBUG_PRINTF ("Thread group has reached maximum number of members.\n");
@@ -423,8 +425,8 @@ spe_setup (spe_gid_t gid, spe_program_ha
 	
 	/* Make the SPU Directory */
 
-	sprintf (pathname, "/spu/spethread-%i-%lu",
-		 getpid (), (unsigned long)thread_store);
+	sprintf (pathname, "%s/spethread-%i-%lu",
+		 grp->pathname, getpid (), (unsigned long)thread_store);
 
 	DEBUG_PRINTF ("create %s\n", pathname);
 
@@ -962,6 +964,11 @@ spe_create_group (int policy, int priori
 			                  policy, priority, use_events);
 	
 	group_store=spe_gid_setup(policy, priority, use_events);
+	snprintf(group_store->pathname, sizeof(group_store->pathname),
+				 "/spu/spegroup-%d-%lu", getpid(), (unsigned long)group_store);
+	group_store->group_fd = spe_create(group_store->pathname,
+				 SPU_CREATE_GANG, 0755);
+
 	DEBUG_PRINTF("gid is %p\n", group_store);
 
 	return group_store;
Index: spe.h
===================================================================
RCS file: /cvs/stiblade/cvs/sw/mercury-l1/libspe/spe.h,v
retrieving revision 1.7
diff -u -p -r1.7 spe.h
--- ./spe.h	2 Jun 2006 14:02:04 -0000	1.7
+++ ./spe.h	15 Jun 2006 16:43:29 -0000
@@ -65,6 +65,8 @@ struct grpListElem
 
 struct group_store
 {
+	char		pathname[256];
+	int		group_fd;
         int 		policy, priority, use_events;
         struct 		grpListElem *grp_members;
         int 		numListSize;
Index: include/sys/spe.h
===================================================================
RCS file: /cvs/stiblade/cvs/sw/mercury-l1/libspe/include/sys/spe.h,v
retrieving revision 1.1
diff -u -p -r1.1 spe.h
--- ./include/sys/spe.h	28 Mar 2006 15:06:08 -0000	1.1
+++ ./include/sys/spe.h	15 Jun 2006 16:43:29 -0000
@@ -22,4 +22,6 @@ static inline int spe_create(const char 
 	return syscall(__NR_spe_create, path, flags, mode);
 }
 
+#define SPU_CREATE_GANG 0x80000000
+
 #endif



More information about the cbe-oss-dev mailing list