From 64ecf6992b5e0400877c2d1b479dddcadac6db69 Mon Sep 17 00:00:00 2001 From: Wilson Fung Date: Fri, 9 Nov 2012 15:33:00 -0800 Subject: Extended PTX parser to recognize the .ptr .shared directive and allocate shared memory buffer to those pointers. This is required to support OpenCL local memorywith the newer NVIDIA driver. [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 14565] --- src/cuda-sim/ptx_parser.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/cuda-sim/ptx_parser.cc') diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc index ddc67c1..d33007b 100644 --- a/src/cuda-sim/ptx_parser.cc +++ b/src/cuda-sim/ptx_parser.cc @@ -55,6 +55,7 @@ int g_error_detected = 0; // type specifier stuff: memory_space_t g_space_spec = undefined_space; +memory_space_t g_ptr_spec = undefined_space; int g_scalar_type_spec = -1; int g_vector_spec = -1; int g_alignment_spec = -1; @@ -127,6 +128,7 @@ void init_directive_state() { DPRINTF("init_directive_state"); g_space_spec=undefined_space; + g_ptr_spec=undefined_space; g_scalar_type_spec=-1; g_vector_spec=-1; g_opcode=-1; @@ -347,7 +349,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident g_last_symbol = s; if( g_func_decl ) return; - std::string msg = std::string(identifier) + " was delcared previous at " + s->decl_location() + " skipping new declaration"; + std::string msg = std::string(identifier) + " was declared previous at " + s->decl_location() + " skipping new declaration"; printf("GPGPU-Sim PTX: Warning %s\n", msg.c_str()); return; } @@ -475,7 +477,8 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident assert( !ti.is_param_unclassified() ); if ( ti.is_param_kernel() ) { - g_func_info->add_param_name_type_size(g_entry_func_param_index,identifier, ti.scalar_type(), num_bits ); + bool is_ptr = (g_ptr_spec != undefined_space); + g_func_info->add_param_name_type_size(g_entry_func_param_index,identifier, ti.scalar_type(), num_bits, is_ptr, g_ptr_spec); g_entry_func_param_index++; } } @@ -516,6 +519,14 @@ void add_alignment_spec( int spec ) g_alignment_spec = spec; } +void add_ptr_spec( enum _memory_space_t spec ) +{ + DPRINTF("add_ptr_spec \"%s\"", g_ptx_token_decode[spec].c_str() ); + parse_assert( g_ptr_spec == undefined_space, "multiple ptr space specifiers not allowed." ); + parse_assert( spec == global_space or spec == local_space or spec == shared_space, "invalid space for ptr directive." ); + g_ptr_spec = spec; +} + void add_space_spec( enum _memory_space_t spec, int value ) { DPRINTF("add_space_spec \"%s\"", g_ptx_token_decode[spec].c_str() ); -- cgit v1.3