Example #1
0
static void init_vl2_pfdevs(QSP_ARG_DECL  Compute_Platform *cpp)
{
	Platform_Device *pdp;

	pdp = new_pfdev(QSP_ARG  "CPU1");
	SET_PFDEV_PLATFORM(pdp,cpp);

	SET_PFDEV_MAX_DIMS(pdp,DEFAULT_PFDEV_MAX_DIMS);

	// set the data area for the device?
	if( ram_area_p == NO_AREA ){
		ram_area_p = pf_area_init(QSP_ARG  "ram",NULL,0L,MAX_RAM_CHUNKS,DA_RAM,pdp);
	}

	SET_PFDEV_AREA(pdp,PFDEV_GLOBAL_AREA_INDEX,ram_area_p);
	SET_AREA_PFDEV( ram_area_p, pdp );
}
Example #2
0
File: ocl.c Project: nasa/QuIP
static void init_ocl_dev_memory(QSP_ARG_DECL  Platform_Device *pdp)
{
	char area_name[MAX_AREA_NAME_LEN+1];
	Data_Area *ap;

	//strcpy(area_name,PFDEV_NAME(pdp));
	// make sure names will fit - longest name is %s.%s_host_mapped
	if( strlen(PLATFORM_NAME(PFDEV_PLATFORM(pdp)))+strlen(PFDEV_NAME(pdp))+strlen("._host_mapped") > MAX_AREA_NAME_LEN )
		error1("init_ocl_dev_memory:  area name too large for buffer, increase MAX_AREA_NAME_LEN!?");

	sprintf(area_name,"%s.%s",
		PLATFORM_NAME(PFDEV_PLATFORM(pdp)),PFDEV_NAME(pdp));

	// what should the name for the memory area be???

	// address set to NULL says use custom allocator - see dobj/makedobj.c

	ap = pf_area_init(area_name,NULL,0, MAX_OCL_GLOBAL_OBJECTS,DA_OCL_GLOBAL,pdp);
	if( ap == NULL ){
		sprintf(ERROR_STRING,
	"init_ocl_dev_memory:  error creating global data area %s",area_name);
		warn(ERROR_STRING);
	}
	// g++ won't take this line!?
	SET_AREA_PFDEV(ap,pdp);

	// BUG should be per-device, not global table...
	pdp->pd_ap[PF_GLOBAL_AREA_INDEX] = ap;

	/* We used to declare a heap for constant memory here,
	 * but there wasn't much of a point because:
	 * Constant memory can't be allocated, rather it is declared
	 * in the .cu code, and placed by the compiler as it sees fit.
	 * To have objects use this, we would have to declare a heap and
	 * manage it ourselves...
	 * There's only 64k, so we should be sparing...
	 * We'll try this later...
	 */


	/* Make up another area for the host memory
	 * which is locked and mappable to the device.
	 * We don't allocate a pool here, but do it as needed...
	 */

	//strcat(cname,"_host");
	sprintf(area_name,"%s.%s_host",
		PLATFORM_NAME(PFDEV_PLATFORM(pdp)),PFDEV_NAME(pdp));

	ap = pf_area_init(area_name,(u_char *)NULL,0,MAX_OCL_MAPPED_OBJECTS,
							DA_OCL_HOST,pdp);
	if( ap == NULL ){
		sprintf(ERROR_STRING,
	"init_ocl_dev_memory:  error creating host data area %s",area_name);
		error1(ERROR_STRING);
	}
	SET_AREA_PFDEV(ap, pdp);
	pdp->pd_ap[PF_HOST_AREA_INDEX] = ap;

	/* Make up another psuedo-area for the mapped host memory;
	 * This is the same memory as above, but mapped to the device.
	 * In the current implementation, we create objects in the host
	 * area, and then automatically create an alias on the device side.
	 * There is a BUG in that by having this psuedo area in the data
	 * area name space, a user could select it as the data area and
	 * then try to create an object.  We will detect this in make_dobj,
	 * and complain.
	 */

	//strcpy(cname,dname);
	//strcat(cname,"_host_mapped");
	sprintf(area_name,"%s.%s_host_mapped",
		PLATFORM_NAME(PFDEV_PLATFORM(pdp)),PFDEV_NAME(pdp));

	ap = pf_area_init(area_name,(u_char *)NULL,0,MAX_OCL_MAPPED_OBJECTS,
						DA_OCL_HOST_MAPPED,pdp);
	if( ap == NULL ){
		sprintf(ERROR_STRING,
	"init_ocl_dev_memory:  error creating host-mapped data area %s",area_name);
		error1(ERROR_STRING);
	}
	SET_AREA_PFDEV(ap,pdp);
	pdp->pd_ap[PF_HOST_MAPPED_AREA_INDEX] = ap;

	if( verbose ){
		sprintf(ERROR_STRING,"init_ocl_dev_memory DONE");
		advise(ERROR_STRING);
	}
}