- do not use GetShortName approach for mmap on windows (#408)
- additional test for long file names on windows Signed-off-by: raver119 <raver119@gmail.com>
This commit is contained in:
		
							parent
							
								
									2ecabde500
								
							
						
					
					
						commit
						8f765c80ff
					
				@ -145,8 +145,6 @@ void _mmap(Nd4jLong* result, size_t length, const char *fileName) {
 | 
			
		||||
    auto shortName = new TCHAR[sz];
 | 
			
		||||
    GetShortPathName(fileName, shortName, sz);
 | 
			
		||||
 | 
			
		||||
    delete[] shortName;
 | 
			
		||||
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
    #pragma warning(push)
 | 
			
		||||
    #pragma warning(disable: 4293)
 | 
			
		||||
@ -170,7 +168,9 @@ void _mmap(Nd4jLong* result, size_t length, const char *fileName) {
 | 
			
		||||
    #pragma warning(pop)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    h = CreateFile(shortName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
 | 
			
		||||
    h = CreateFileA(fileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
 | 
			
		||||
 | 
			
		||||
    delete[] shortName;
 | 
			
		||||
 | 
			
		||||
    if (h == INVALID_HANDLE_VALUE) {
 | 
			
		||||
        errno = __map_mman_error(GetLastError(), EPERM);
 | 
			
		||||
 | 
			
		||||
@ -357,6 +357,29 @@ public class SpecialWorkspaceTests extends BaseNd4jTest {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testMmapedWorkspace_Path_Limits_1() throws Exception {
 | 
			
		||||
        if (!Nd4j.getEnvironment().isCPU())
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        // getting very long file name
 | 
			
		||||
        val builder = new StringBuilder("long_file_name_");
 | 
			
		||||
        for (int e = 0; e < 100; e++)
 | 
			
		||||
            builder.append("9");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        val tmpFile = Files.createTempFile("some", builder.toString());
 | 
			
		||||
        val mmap = WorkspaceConfiguration.builder()
 | 
			
		||||
                .initialSize(200 * 1024L * 1024L) // 200mbs
 | 
			
		||||
                .tempFilePath(tmpFile.toAbsolutePath().toString())
 | 
			
		||||
                .policyLocation(LocationPolicy.MMAP)
 | 
			
		||||
                .build();
 | 
			
		||||
 | 
			
		||||
        try (val ws = Nd4j.getWorkspaceManager().getAndActivateWorkspace(mmap, "M2")) {
 | 
			
		||||
            val x = Nd4j.rand(DataType.FLOAT, 1024);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public char ordering() {
 | 
			
		||||
        return 'c';
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user