Exemplo n.º 1
0
phys_size_t initdram (int board_type)
{
	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
	volatile memctl8260_t *memctl = &immap->im_memctl;

#ifndef CONFIG_SYS_RAMBOOT
	ulong size8, size9;
#endif
	ulong psize = 32 * 1024 * 1024;

	memctl->memc_psrt = CONFIG_SYS_PSRT;
	memctl->memc_mptpr = CONFIG_SYS_MPTPR;

#ifndef CONFIG_SYS_RAMBOOT
	size8 = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR2_8COL,
					  (uchar *) CONFIG_SYS_SDRAM_BASE);
	size9 = try_init (memctl, CONFIG_SYS_PSDMR_9COL, CONFIG_SYS_OR2_9COL,
					  (uchar *) CONFIG_SYS_SDRAM_BASE);

	if (size8 < size9) {
		psize = size9;
		printf ("(60x:9COL) ");
	} else {
		psize = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR2_8COL,
						  (uchar *) CONFIG_SYS_SDRAM_BASE);
		printf ("(60x:8COL) ");
	}
#endif
	return (psize);
}
Exemplo n.º 2
0
phys_size_t initdram (int board_type)
{
	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
	volatile memctl8260_t *memctl = &immap->im_memctl;
	long psize;
#ifndef CONFIG_SYS_RAMBOOT
	long sizelittle, sizebig;
#endif

	memctl->memc_psrt = CONFIG_SYS_PSRT;
	memctl->memc_mptpr = CONFIG_SYS_MPTPR;

#ifndef CONFIG_SYS_RAMBOOT
	/* 60x SDRAM setup:
	 */
	sizelittle = try_init (memctl, CONFIG_SYS_PSDMR_LITTLE, CONFIG_SYS_OR1_LITTLE,
						  (uchar *) CONFIG_SYS_SDRAM_BASE);
	sizebig = try_init (memctl, CONFIG_SYS_PSDMR_BIG, CONFIG_SYS_OR1_BIG,
						  (uchar *) CONFIG_SYS_SDRAM_BASE);
	if (sizelittle < sizebig) {
		psize = sizebig;
	} else {
		psize = try_init (memctl, CONFIG_SYS_PSDMR_LITTLE, CONFIG_SYS_OR1_LITTLE,
						  (uchar *) CONFIG_SYS_SDRAM_BASE);
	}
#endif /* CONFIG_SYS_RAMBOOT */

	icache_enable ();

	return (psize);
}
Exemplo n.º 3
0
static int do_init(FILE *f)
{
    assert(con_mode == CON_INIT);

    try_init(&console_none,f);
    assert(con != me);
    assert(con == &console_none);
    assert(con_mode == CON_NONE);
    if (opt_console == CON_NONE)
        return con_mode;
    if (!acc_isatty(STDIN_FILENO) || !acc_isatty(STDOUT_FILENO) || !acc_isatty(STDERR_FILENO))
        return con_mode;

#if defined(USE_ANSI)
    try_init(&console_ansi_mono,f);
    try_init(&console_ansi_color,f);
#endif
#if defined(USE_SCREEN)
    try_init(&console_screen,f);
#endif
#if defined(USE_AALIB)
    try_init(&console_aalib,f);
#endif

    return con_mode;
}
Exemplo n.º 4
0
void swanLoadProgramFromSource(  const char *module, const unsigned  char *ptx, size_t len , int devtype ) {
	int i=0;
	CUresult err;
	try_init();
	// let's see whether this module is already loaded
	for( i=0; i < state.num_mods; i++ ) {
		if( !strcmp( state.mod_names[i], module ) ) {
			return; // already loaded
		}
	} 	

	if( ptx == NULL || len == 0 ) {
		fprintf ( stderr, "SWAN : Module load failure [%s]. No source \n", module );
		error( "Module source invalid" );
	}

	i = state.num_mods;
	state.num_mods++;
	state.mods         = (CUmodule*) realloc( state.mods, state.num_mods * sizeof(CUmodule) );
	state.mod_names    = (char**) realloc( state.mod_names, state.num_mods * sizeof(char*) );
	state.mod_names[i] = (char*) malloc( strlen( module ) + 1 );
	strcpy( state.mod_names[i], module );

	// now load the PTX into a module
	err = cuModuleLoadData( &state.mods[i], ptx );
	if( err != CUDA_SUCCESS ) {
		fprintf ( stderr, "SWAN : Module load result [%s] [%d]\n", module, err );
		error( "Module load failed\n" );
	}
	
}
Exemplo n.º 5
0
void *swanMalloc( size_t len ) {
	void *ptr;
	CUdeviceptr dptr;
	CUresult err;
	try_init();
	if( len == 0 ) {
//		printf("SWAN: WARNING - swnaMalloc() called with 0\n");
		return NULL;
	}

	err = cuMemAlloc( (CUdeviceptr*) &dptr, len );
	
	ptr = (void*)dptr;

	if ( err != CUDA_SUCCESS ) {
		printf("Attempted to allocate %lu bytes (%lu already allocated)\n", len, state.bytes_allocated );
	abort();
		error("swanMalloc failed\n" );
	}
	state.bytes_allocated += len;


	// MJH likes his memory clean
	swanMemset( ptr, 0, len );
	return ptr;
}
Exemplo n.º 6
0
size_t swanMemAvailable( void ) {
	size_t free, total;
	try_init();

	cuMemGetInfo( &free, &total );
	
	return free;
}
Exemplo n.º 7
0
long int initdram (int board_type)
{
	volatile immap_t *immap = (immap_t *) CFG_IMMR;
	volatile memctl8260_t *memctl = &immap->im_memctl;

#ifndef CFG_RAMBOOT
	ulong size8, size9, size10;
#endif
	long psize;

	psize = 32 * 1024 * 1024;

	memctl->memc_mptpr = CFG_MPTPR;
	memctl->memc_psrt = CFG_PSRT;

#ifndef CFG_RAMBOOT
	/* 60x SDRAM setup:
	 */
	size8 = try_init (memctl, CFG_PSDMR_8COL, CFG_OR2_8COL,
			  (uchar *) CFG_SDRAM_BASE);

	size9 = try_init (memctl, CFG_PSDMR_9COL, CFG_OR2_9COL,
			  (uchar *) CFG_SDRAM_BASE);

	size10 = try_init (memctl, CFG_PSDMR_10COL, CFG_OR2_10COL,
			  (uchar *) CFG_SDRAM_BASE);

	psize = max(size8,max(size9,size10));

	if (psize == size8) {
		psize = try_init (memctl, CFG_PSDMR_8COL, CFG_OR2_8COL,
				  (uchar *) CFG_SDRAM_BASE);
		printf ("(60x:8COL) ");
	} else if (psize == size9){
		psize = try_init (memctl, CFG_PSDMR_9COL, CFG_OR2_9COL,
				  (uchar *) CFG_SDRAM_BASE);
		printf ("(60x:9COL) ");
	} else
		printf ("(60x:10COL) ");

#endif	/* CFG_RAMBOOT */

	icache_enable ();

	return (psize);
}
Exemplo n.º 8
0
modland_data_t *modland_lookup(const char *md5) {
    try_init();

    if (!initialized) {
        return NULL;
    }

    return modland_internal_lookup(md5);
}
Exemplo n.º 9
0
static long probe_sdram(memctl8260_t *memctl)
{
	int n = 0;
	long psize = 0;

	for (n = 0; n < ARRAY_SIZE(sdram_conf); psize = 0, n++) {
		psize = try_init(memctl,
			CONFIG_SYS_PSDMR | sdram_conf[n].psdmr,
			CONFIG_SYS_OR1 | sdram_conf[n].or1,
			(uchar *) CONFIG_SYS_SDRAM_BASE);
		debug("Probing %ld bytes returned %ld\n",
			sdram_conf[n].size, psize);
		if (psize == sdram_conf[n].size)
			break;
	}
	return psize;
}
Exemplo n.º 10
0
void *swanMallocHost( size_t len ) {
	CUresult err;
	void *ptr;
	try_init();

#ifdef DEV_EXTENSIONS
	err= cuMemHostAlloc( &ptr, len, CU_MEMHOSTALLOC_PORTABLE  ); //| CU_MEMHOSTALLOC_DEVICEMAP  ); //| CU_MEMHOSTALLOC_WRITECOMBINED );
#else
	err = cuMemAllocHost( &ptr, len );
#endif

	if ( err != CUDA_SUCCESS ) {
		fprintf( stderr, "swanMallocHost error: %d\n", err );
		error("swanMallocHost failed\n" );
	}
//	printf("MallocHost %p\n", ptr );
	memset( ptr, 0, len );
	return ptr;
}
Exemplo n.º 11
0
phys_size_t initdram (int board_type)
{
	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
	volatile memctl8260_t *memctl = &immap->im_memctl;

	long psize;

	memctl->memc_psrt = CONFIG_SYS_PSRT;
	memctl->memc_mptpr = CONFIG_SYS_MPTPR;

#ifndef CONFIG_SYS_RAMBOOT
	/* 60x SDRAM setup:
	 */
	psize = try_init (memctl, CONFIG_SYS_PSDMR, CONFIG_SYS_OR1,
						  (uchar *) CONFIG_SYS_SDRAM_BASE);
#endif /* CONFIG_SYS_RAMBOOT */

	icache_enable ();

	return (psize);
}
Exemplo n.º 12
0
static long probe_sdram(memctl8260_t *memctl)
{
	return try_init(memctl, CONFIG_SYS_PSDMR, CONFIG_SYS_OR1,
					(uchar *) CONFIG_SYS_SDRAM_BASE);
}
Exemplo n.º 13
0
void swanInit(void) { 
	try_init(); 
}
Exemplo n.º 14
0
void swanRunKernelAsync( const char *kernel,  block_config_t grid , block_config_t block, size_t shmem, int flags, void *ptrs[], int *types  ) {
	// find the kernel

	if( !grid.x || !grid.y || !grid.z || !block.x || !block.y || !block.z ) { return; } // suppress launch of kernel if any of the launch dims are 0

	CUfunction f = NULL;
	int i;
	int offset = 0;
	CUresult err;

	int type;
	int idx=0;
	try_init();
	for( i=0; i < state.num_funcs; i++ ) {
		if( !strcmp( state.func_names[i], kernel ) ) {
			f = state.funcs[i];
			break;
		}
	}

	if( f == NULL ) {
		for( i=0; i < state.num_mods; i++ ) {
			cuModuleGetFunction( &f, state.mods[i], kernel );
			if( f!= NULL ) { 
				// found a kernel. store it for future use
				int j = state.num_funcs;
				state.num_funcs++;
				state.funcs      = (CUfunction*) realloc( state.funcs, sizeof(CUfunction) * state.num_funcs );
				state.funcs[j]   = f;
				state.func_names = (char**)      realloc( state.func_names, sizeof(char*) * state.num_funcs );
				state.func_names[j] = (char*) malloc( strlen(kernel) + 1 );
				strcpy( state.func_names[j], kernel );
				break; 
			}
		}
	}

	if( f== NULL ) {
		fprintf(stderr, "Error running kernel [%s] : \n", kernel );
		error( "No kernel found" );
	}

	if( grid.z != 1 ) {
		printf("Kernel [%s] launched with (%d %d %d)(%d %d %d)\n", kernel, grid.x, grid.y, grid.z, block.x, block.y, block.z );
		error( "grid.z needs to be 1" );
	}

//printf("Running kernel [%s]\n", kernel );

	type = types[idx];
	while( type != SWAN_END ) {
		void *ptr = ptrs[idx];
		switch( type ) {
//			DEBLOCK( SWAN_uchar, uchar,  1 );
			DEBLOCK( SWAN_uchar2, uchar2,  2 );
			DEBLOCK( SWAN_uchar3, uchar3,  1 );
			DEBLOCK( SWAN_uchar4, uchar4,  4 );
			DEBLOCK( SWAN_char , int,  1 );
//			DEBLOCK( SWAN_char1 , char1,  1 );
			DEBLOCK( SWAN_char2 , char2,  2 );
			DEBLOCK( SWAN_char3 , char3,  1 );
			DEBLOCK( SWAN_char4 , char4,  4 );
			DEBLOCK( SWAN_int, int,  4 );
//			DEBLOCK( SWAN_int1, int1,  4 );
			DEBLOCK( SWAN_int2, int2,  8 );
			DEBLOCK( SWAN_int3, int3,  4 );
			DEBLOCK( SWAN_int4, int4,  16 );
//			DEBLOCK( SWAN_float, double,  4 );
//			DEBLOCK( SWAN_float1, float1,  4 );
			DEBLOCK( SWAN_float2, float2,  8 );
			DEBLOCK( SWAN_float3, float3,  4 );
			DEBLOCK( SWAN_float4, float4,  16 );

			DEBLOCK( SWAN_uint, uint,  4 );
			DEBLOCK( SWAN_uint2, uint2,  8 );
			DEBLOCK( SWAN_uint3, uint3,  4 );
			DEBLOCK( SWAN_uint4, uint4,  16 );
			DEBLOCK( SWAN_float, float,  4 );


//#define DEBLOCK(swan_type,type,OFFSET) 
#if ( CUDA_MAJOR == 3 && CUDA_MINOR >= 2 ) || CUDA_MAJOR >= 4
			case SWAN_PTR: 
				{
//printf("PTR as NATIVE\n");
				ALIGN_UP( offset, (sizeof(void*)));
				cuParamSetv( f, offset, ptr, sizeof(void*) );
				offset += sizeof(void*); }
			break;
#else
			case SWAN_PTR: 
				{
//printf("PTR as INT\n");
				ALIGN_UP( offset, (sizeof(int)));
				cuParamSetv( f, offset, ptr, sizeof(int) );
				offset += sizeof(int); }
			break;
#endif



			default:
        printf("%d\n", type );
				error("Parameter type not handled\n");


		}
		idx++;
		type = types[idx];
	}

//printf("Launching kernel [%s] [%X]  with (%d %d %d) (%d %d %d)\n", kernel, f, grid.x, grid.y, grid.z, block.x, block.y, block.z );
//printf(" TOTAL OFFSET %d\n", offset );
	CU_SAFE_CALL_NO_SYNC( cuParamSetSize( f, offset ) );
	CU_SAFE_CALL_NO_SYNC( cuFuncSetBlockShape( f, block.x, block.y, block.z ) );
	CU_SAFE_CALL_NO_SYNC( cuFuncSetSharedSize( f, shmem ) );
#if (CUDA_MAJOR ==3 && CUDA_MINOR >=1 ) || CUDA_MAJOR>=4
	cuFuncSetCacheConfig( f, CU_FUNC_CACHE_PREFER_SHARED ); // This seems to be better in every case for acemd
#endif

	err = cuLaunchGridAsync( f, grid.x, grid.y, NULL ) ; //state.stream ) ;

	if( err != CUDA_SUCCESS ) {
		fprintf( stderr , "SWAN : FATAL : Failure executing kernel [%s] [%d] [%d,%d,%d][%d,%d,%d]\n", kernel, err, grid.x ,grid.y, grid.z, block.x, block.y, block.z );
	assert(0);
		exit(-99);
	}

//printf("Kernel completed\n" );
}
Exemplo n.º 15
0
int swanDeviceVersion( void ) {
	try_init();

	return state.device_version;

}
Exemplo n.º 16
0
int swanGetNumberOfComputeElements( void ) {
	try_init();
//	struct cudaDeviceProp prop;
//	cudaGetDeviceProperties( &prop, state.device );
	return state.multiProcessorCount;
}
Exemplo n.º 17
0
void SIM_init(){
	sky_pref_t* pref;
	char* welcome_str = get_front_message();
	/* 
	 * get the corrent_config_file and do some initialization 
	 */
	skyeye_config_t* config = get_current_config();
	skyeye_option_init(config);
	/*
	 * initialization of callback data structure, it needs to 
	 * be initialized at very beginning.
	 */
	init_callback();

	/*
	 * initilize the data structure for command
	 * register some default built-in command
	 */
	init_command_list();

	init_stepi();

	/*
	 * initialization of module manangement 
	 */
	init_module_list();

	
	/*
	 * initialization of architecture and cores
	 */
	init_arch();
	
	/*
	 * initialization of bus and memory module
	 */
	init_bus();


	/*
	 * initialization of machine module
	 */
	init_mach();

	
	/*
	 * initialization of breakpoint, that depends on callback module.
	 */
	init_bp();

	/* 
	 * get the current preference for simulator 
	 */
	pref = get_skyeye_pref();

	/* 
	 * loading all the modules in search directory 
	 */
	if(!pref->module_search_dir)
		pref->module_search_dir = skyeye_strdup(default_lib_dir);
	SKY_load_all_modules(pref->module_search_dir, NULL);
	//skyeye_config_t *config;
	//config = malloc(sizeof(skyeye_config_t));
	if(try_init() == No_exp){
		if(pref->autoboot == True){
			SIM_run();
		}
	}
	/*
	 * if we run simulator in GUI or external IDE, we do not need to
	 * launch our CLI.
	 */
	if(pref->interactive_mode == True){
		SIM_cli();		
	}
}