Example #1
0
    def test_open_acc_object_from_basic_file(self):
        """
            To create ccode objects , the given code must follow 
            the following struture

            #include <...>
            #include <...>

            #define ....

            
            function_1(){
        
            }

            int main(){
        
            }

            if the given code do not follow this structure it can 
            not be splited in sections, because the code does not
            have that sections, then an IndexError takes place.
        """
        with self.assertRaises(IndexError):
            acc = parallelizer.OpenACC(file_path=self._basic)
Example #2
0
 def test_open_acc_object_from_unsupported_code_1(self):
     """ 
         The C preprocessor used by pycparse for code parsing do not support
         the bool type natively, if the preprocessor find an unknwon type, the
         code parsing cann not take place.
     """
     with self.assertRaises(ParseError):
         acc = parallelizer.OpenACC(file_path=self._unsupported_1)
Example #3
0
    def setUp(self):
        # Creating the OpenMP parallelizer
        self._acc = parallelizer.OpenACC(
            raw_code=test_data.SIMPLE_CODE_FUNCTION_LOOP)

        # Creation paralellization metadata object
        self._parallel = metadata.Parallel(
            data=test_data.METADATA_FOR_SIMPLE_CODE_FUNCTION_LOOP)
Example #4
0
    def test_open_acc_object_from_supported_code(self):
        """

            We place two includes above the stdbool.h

            #include <stdio.h>
            #include <stdlib.h>
            #include <stdbool.h>

            So the first two includes are faked out

            #include <_fake_defines.h>
            #include <_fake_typedefs.h>
            #include <stdbool.h>

            Then, the bool type will be recognized by the following step,
            The C preprocessing.          

        """
        acc = parallelizer.OpenACC(file_path=self._supported)
        self.assertIsInstance(acc, parallelizer.OpenACC)
Example #5
0
    def test_open_acc_object_from__unsupported_code_2(self):
        """ 
            We include the stdbool.h header library on which the bool 
            type is defined. Thus, the C preprocessor will recognize
            the bool type.

            But this version of pragcc perform a preprocessing if the
            code called fake_cfile located in pragcc.core.parser.c99.parser
            this step remove the first two headers of the original file.

            #include <stdbool.h>
            #include <stdio.h>

            for fake files

            #include <_fake_defines.h>
            #include <_fake_typedefs.h>

            So, the bool type would not be recognized again. The follwing 
            test show a possible solution.

        """
        with self.assertRaises(ParseError):
            acc = parallelizer.OpenACC(file_path=self._unsupported_2)
Example #6
0
 def test_open_acc_object_from_empty_code_file(self):
     with self.assertRaises(IndexError):
         acc = parallelizer.OpenACC(file_path=self._empty)
Example #7
0
 def test_open_acc_object_from_complex_file(self):
     acc = parallelizer.OpenACC(file_path=self._complex)
     self.assertIsInstance(acc, parallelizer.OpenACC)