Changeset 4954 in CLRX


Ignore:
Timestamp:
Sep 11, 2019, 4:41:37 PM (7 days ago)
Author:
matszpk
Message:

CLRadeonExtender: ROCmBin: Fixed MsgPack? writer classes constructors for long elements number. Add next testcases.

Location:
CLRadeonExtender/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdbin/ROCmMetadataMP.cpp

    r4953 r4954  
    10831083        d[0] = 0xdd;
    10841084        uint32_t v2 = elemsNum;
    1085         for (cxuint i=5; i >= 0; i--, v2>>=8)
     1085        for (cxint i=4; i > 0; i--, v2>>=8)
    10861086            d[i] = v2&0xff;
    1087         output.insert(output.end(), d, d+3);
     1087        output.insert(output.end(), d, d+5);
    10881088    }
    10891089}
     
    11471147        d[0] = 0xdf;
    11481148        uint32_t v2 = elemsNum;
    1149         for (cxuint i=5; i >= 0; i--, v2>>=8)
     1149        for (cxint i=4; i > 0; i--, v2>>=8)
    11501150            d[i] = v2&0xff;
    1151         output.insert(output.end(), d, d+3);
     1151        output.insert(output.end(), d, d+5);
    11521152    }
    11531153}
  • CLRadeonExtender/trunk/tests/amdbin/ROCmMsgPackWrite.cpp

    r4953 r4954  
    2020#include <CLRX/Config.h>
    2121#include <iostream>
    22 #include <sstream>
    23 #include <string>
    2422#include <cstring>
     23#include <vector>
    2524#include <memory>
    2625#include <CLRX/utils/Containers.h>
     
    3231static void testMsgPackBytesWrite()
    3332{
     33    {
     34        static const cxbyte outBytes0[3] = { 0x92, 0xc3, 0xc2 };
     35        std::vector<cxbyte> out;
     36        MsgPackArrayWriter awriter(2, out);
     37        awriter.putBool(true);
     38        awriter.putBool(false);
     39        assertArray("MsgPackWrite0", "tc0",
     40                    Array<cxbyte>(outBytes0, outBytes0 + sizeof(outBytes0)), out);
     41    }
     42    {
     43        static const cxbyte outBytes1[16] = { 0x9f, 0, 1, 2, 3, 4, 5, 6, 7,
     44            8, 9, 10, 11, 12, 13, 14 };
     45        std::vector<cxbyte> out;
     46        MsgPackArrayWriter awriter(15, out);
     47        for (cxuint i = 0; i < 15; i++)
     48            awriter.putUInt(i);
     49        assertArray("MsgPackWrite0", "tc1",
     50                    Array<cxbyte>(outBytes1, outBytes1 + sizeof(outBytes1)), out);
     51    }
     52    {   // longer array
     53        static const cxbyte outBytes2[21] = { 0xdc, 0x0, 0x12, 0, 1, 2, 3, 4, 5, 6, 7,
     54            8, 9, 10, 11, 12, 13, 14, 15, 16, 17 };
     55        std::vector<cxbyte> out;
     56        MsgPackArrayWriter awriter(18, out);
     57        for (cxuint i = 0; i < 18; i++)
     58            awriter.putUInt(i);
     59        assertArray("MsgPackWrite0", "tc2",
     60                    Array<cxbyte>(outBytes2, outBytes2 + sizeof(outBytes2)), out);
     61    }
     62    {   // long array (12222 elements)
     63        Array<cxbyte> outBytes3(12222+3);
     64        outBytes3[0] = 0xdc;
     65        outBytes3[1] = 12222>>8;
     66        outBytes3[2] = 12222&0xff;
     67        std::vector<cxbyte> out;
     68        MsgPackArrayWriter awriter(12222, out);
     69        for (cxuint i = 0; i < 12222; i++)
     70        {
     71            awriter.putUInt(i&0x7f);
     72            outBytes3[i+3] = i&0x7f;
     73        }
     74        assertArray("MsgPackWrite0", "tc3", outBytes3, out);
     75    }
     76    {   // long array (12222 elements)
     77        Array<cxbyte> outBytes3(1777777+5);
     78        outBytes3[0] = 0xdd;
     79        outBytes3[1] = 1777777>>24;
     80        outBytes3[2] = (1777777>>16)&0xff;
     81        outBytes3[3] = (1777777>>8)&0xff;
     82        outBytes3[4] = 1777777&0xff;
     83        std::vector<cxbyte> out;
     84        MsgPackArrayWriter awriter(1777777, out);
     85        for (cxuint i = 0; i < 1777777; i++)
     86        {
     87            awriter.putUInt(i&0x7f);
     88            outBytes3[i+5] = i&0x7f;
     89        }
     90        assertArray("MsgPackWrite0", "tc4", outBytes3, out);
     91    }
    3492}
    3593
Note: See TracChangeset for help on using the changeset viewer.